diff --git a/qgroundcontrol.pri b/qgroundcontrol.pri index fd7c590..88d42d8 100644 --- a/qgroundcontrol.pri +++ b/qgroundcontrol.pri @@ -18,7 +18,7 @@ # ------------------------------------------------- message(Qt version $$[QT_VERSION]) -message(Using Qt from $(QTDIR)) +message(Using Qt from $$(QTDIR)) QT_DIR = $$(QTDIR) diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 7b645d1..93c4ec3 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -360,6 +360,7 @@ SOURCES += src/main.cc \ src/uas/UASManager.cc \ src/uas/UAS.cc \ src/comm/LinkManager.cc \ + src/comm/LinkInterface.cpp \ src/comm/SerialLink.cc \ src/comm/SerialSimulationLink.cc \ src/comm/MAVLinkProtocol.cc \ diff --git a/src/comm/LinkInterface.cpp b/src/comm/LinkInterface.cpp new file mode 100644 index 0000000..1c30413 --- /dev/null +++ b/src/comm/LinkInterface.cpp @@ -0,0 +1,6 @@ +#include "LinkInterface.h" + +LinkInterface::~LinkInterface() +{ + emit this->deleteLink(this); +} \ No newline at end of file diff --git a/src/comm/LinkInterface.h b/src/comm/LinkInterface.h index 8753a6c..72e2dd2 100644 --- a/src/comm/LinkInterface.h +++ b/src/comm/LinkInterface.h @@ -44,7 +44,7 @@ class LinkInterface : public QThread Q_OBJECT public: LinkInterface(QObject* parent = 0) : QThread(parent) {} - //virtual ~LinkInterface() = 0; + virtual ~LinkInterface()=0; /* Connection management */ @@ -232,6 +232,9 @@ signals: /** @brief Communication error occured */ void communicationError(const QString& linkname, const QString& error); + /** @brief destroying element */ + void deleteLink(LinkInterface* const link); + protected: static int getNextLinkId() { static int nextId = 0; diff --git a/src/ui/DebugConsole.cc b/src/ui/DebugConsole.cc index f3fab5d..a65e6de 100644 --- a/src/ui/DebugConsole.cc +++ b/src/ui/DebugConsole.cc @@ -180,12 +180,12 @@ void DebugConsole::addLink(LinkInterface* link) // Register for name changes connect(link, SIGNAL(nameChanged(QString)), this, SLOT(updateLinkName(QString))); - connect(link, SIGNAL(destroyed(QObject*)), this, SLOT(removeLink(QObject*))); + connect(link, SIGNAL(deleteLink(LinkInterface* const)), this, SLOT(removeLink(LinkInterface* const))); } -void DebugConsole::removeLink(QObject* link) +void DebugConsole::removeLink(LinkInterface* const linkInterface) { - LinkInterface* linkInterface = dynamic_cast(link); + //LinkInterface* linkInterface = dynamic_cast(link); // Add link to link list if (links.contains(linkInterface)) { int linkIndex = links.indexOf(linkInterface); @@ -194,7 +194,7 @@ void DebugConsole::removeLink(QObject* link) m_ui->linkComboBox->removeItem(linkIndex); } - if (link == currLink) currLink = NULL; + if (linkInterface == currLink) currLink = NULL; } void DebugConsole::linkSelected(int linkId) diff --git a/src/ui/DebugConsole.h b/src/ui/DebugConsole.h index 0b77e8c..252e7ee 100644 --- a/src/ui/DebugConsole.h +++ b/src/ui/DebugConsole.h @@ -62,7 +62,7 @@ public slots: /** @brief Add a link to the list of monitored links */ void addLink(LinkInterface* link); /** @brief Remove a link from the list */ - void removeLink(QObject* link); + void removeLink(LinkInterface* const link); /** @brief Update a link name */ void updateLinkName(QString name); /** @brief Select a link for the active view */