From 15dc92371af74c8ef7be3db03675e7940335cb8e Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Wed, 26 Nov 2014 18:28:29 -0800 Subject: [PATCH] Guard again deletes not from LinkManager --- src/comm/LinkInterface.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/comm/LinkInterface.h b/src/comm/LinkInterface.h index 35139100e..88539ed22 100644 --- a/src/comm/LinkInterface.h +++ b/src/comm/LinkInterface.h @@ -54,7 +54,9 @@ class LinkInterface : public QThread public: LinkInterface() : - QThread(0) + QThread(0), + _ownedByLinkManager(false), + _deletedByLinkManager(false) { // Initialize everything for the data rate calculation buffers. inDataIndex = 0; @@ -73,7 +75,9 @@ public: } virtual ~LinkInterface() { - emit this->deleteLink(this); + // LinkManager take ownership of Links once they are added to it. Once added to LinkManager + // user LinkManager::deleteLink to remove if necessary/ + Q_ASSERT(!_ownedByLinkManager || _deletedByLinkManager); } /* Connection management */ @@ -197,9 +201,6 @@ signals: void communicationUpdate(const QString& linkname, const QString& text); - /** @brief destroying element */ - void deleteLink(LinkInterface* const link); - protected: static const int dataRateBufferSize = 20; ///< Specify how many data points to capture for data rate calculations. @@ -334,6 +335,11 @@ private: * @return True if connection could be terminated, false otherwise **/ virtual bool _disconnect(void) = 0; + + bool _ownedByLinkManager; ///< true: This link has been added to LinkManager, false: Link not added to LinkManager + bool _deletedByLinkManager; ///< true: Link being deleted from LinkManager, false: error, Links should only be deleted from LinkManager + + friend class LinkManager; }; #endif // _LINKINTERFACE_H_ -- 2.22.0