Browse Source

Fix UAS unit test

Destroyed signal must have been working incorrectly in the past.
QGC4.4
Don Gagne 11 years ago
parent
commit
6d447410b4
  1. 3
      src/qgcunittest/UASUnitTest.cc
  2. 9
      src/uas/UAS.cc

3
src/qgcunittest/UASUnitTest.cc

@ -301,7 +301,6 @@ void UASUnitTest::signalWayPoint_test() @@ -301,7 +301,6 @@ void UASUnitTest::signalWayPoint_test()
void UASUnitTest::signalUASLink_test()
{
QSignalSpy spy(uas, SIGNAL(modeChanged(int,QString,QString)));
uas->setMode(2, 0);
QCOMPARE(spy.count(), 0);// not solve for UAS not receiving message from UAS
@ -347,7 +346,7 @@ void UASUnitTest::signalUASLink_test() @@ -347,7 +346,7 @@ void UASUnitTest::signalUASLink_test()
delete link2;
QCOMPARE(LinkManager::instance()->getLinks().count(), 1);
QCOMPARE(uas->getLinks()->count(), 2);
QCOMPARE(uas->getLinks()->count(), 1);
QCOMPARE(static_cast<LinkInterface*>(LinkManager::instance()->getLinks().at(0))->getId(),
static_cast<LinkInterface*>(uas->getLinks()->at(0))->getId());

9
src/uas/UAS.cc

@ -3375,8 +3375,13 @@ void UAS::addLink(LinkInterface* link) @@ -3375,8 +3375,13 @@ void UAS::addLink(LinkInterface* link)
void UAS::removeLink(QObject* object)
{
// Be careful of the fact that by the time this signal makes it through the queue
// the link object has already been destructed.
links->removeAt(links->indexOf((LinkInterface*)object));
// the link object has already been destructed. So no dynamic_cast for example.
LinkInterface* link = (LinkInterface*)object;
int index = links->indexOf(link);
Q_ASSERT(index != -1);
links->removeAt(index);
}
/**

Loading…
Cancel
Save