Browse Source

Debug console bugfix

QGC4.4
oberion 14 years ago
parent
commit
9136d5396e
  1. 2
      qgroundcontrol.pri
  2. 1
      qgroundcontrol.pro
  3. 6
      src/comm/LinkInterface.cpp
  4. 5
      src/comm/LinkInterface.h
  5. 8
      src/ui/DebugConsole.cc
  6. 2
      src/ui/DebugConsole.h

2
qgroundcontrol.pri

@ -18,7 +18,7 @@
# ------------------------------------------------- # -------------------------------------------------
message(Qt version $$[QT_VERSION]) message(Qt version $$[QT_VERSION])
message(Using Qt from $(QTDIR)) message(Using Qt from $$(QTDIR))
QT_DIR = $$(QTDIR) QT_DIR = $$(QTDIR)

1
qgroundcontrol.pro

@ -360,6 +360,7 @@ SOURCES += src/main.cc \
src/uas/UASManager.cc \ src/uas/UASManager.cc \
src/uas/UAS.cc \ src/uas/UAS.cc \
src/comm/LinkManager.cc \ src/comm/LinkManager.cc \
src/comm/LinkInterface.cpp \
src/comm/SerialLink.cc \ src/comm/SerialLink.cc \
src/comm/SerialSimulationLink.cc \ src/comm/SerialSimulationLink.cc \
src/comm/MAVLinkProtocol.cc \ src/comm/MAVLinkProtocol.cc \

6
src/comm/LinkInterface.cpp

@ -0,0 +1,6 @@
#include "LinkInterface.h"
LinkInterface::~LinkInterface()
{
emit this->deleteLink(this);
}

5
src/comm/LinkInterface.h

@ -44,7 +44,7 @@ class LinkInterface : public QThread
Q_OBJECT Q_OBJECT
public: public:
LinkInterface(QObject* parent = 0) : QThread(parent) {} LinkInterface(QObject* parent = 0) : QThread(parent) {}
//virtual ~LinkInterface() = 0; virtual ~LinkInterface()=0;
/* Connection management */ /* Connection management */
@ -232,6 +232,9 @@ signals:
/** @brief Communication error occured */ /** @brief Communication error occured */
void communicationError(const QString& linkname, const QString& error); void communicationError(const QString& linkname, const QString& error);
/** @brief destroying element */
void deleteLink(LinkInterface* const link);
protected: protected:
static int getNextLinkId() { static int getNextLinkId() {
static int nextId = 0; static int nextId = 0;

8
src/ui/DebugConsole.cc

@ -180,12 +180,12 @@ void DebugConsole::addLink(LinkInterface* link)
// Register for name changes // Register for name changes
connect(link, SIGNAL(nameChanged(QString)), this, SLOT(updateLinkName(QString))); 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<LinkInterface*>(link); //LinkInterface* linkInterface = dynamic_cast<LinkInterface*>(link);
// Add link to link list // Add link to link list
if (links.contains(linkInterface)) { if (links.contains(linkInterface)) {
int linkIndex = links.indexOf(linkInterface); int linkIndex = links.indexOf(linkInterface);
@ -194,7 +194,7 @@ void DebugConsole::removeLink(QObject* link)
m_ui->linkComboBox->removeItem(linkIndex); m_ui->linkComboBox->removeItem(linkIndex);
} }
if (link == currLink) currLink = NULL; if (linkInterface == currLink) currLink = NULL;
} }
void DebugConsole::linkSelected(int linkId) void DebugConsole::linkSelected(int linkId)

2
src/ui/DebugConsole.h

@ -62,7 +62,7 @@ public slots:
/** @brief Add a link to the list of monitored links */ /** @brief Add a link to the list of monitored links */
void addLink(LinkInterface* link); void addLink(LinkInterface* link);
/** @brief Remove a link from the list */ /** @brief Remove a link from the list */
void removeLink(QObject* link); void removeLink(LinkInterface* const link);
/** @brief Update a link name */ /** @brief Update a link name */
void updateLinkName(QString name); void updateLinkName(QString name);
/** @brief Select a link for the active view */ /** @brief Select a link for the active view */

Loading…
Cancel
Save