diff --git a/libretroshare/src/pqi/rstcpsocket.cc b/libretroshare/src/pqi/rstcpsocket.cc index f42f100a2..f9bf03483 100644 --- a/libretroshare/src/pqi/rstcpsocket.cc +++ b/libretroshare/src/pqi/rstcpsocket.cc @@ -84,7 +84,7 @@ RsThreadedTcpSocket::RsThreadedTcpSocket() : RsTcpSocket() } void RsThreadedTcpSocket::run() { - while(connectionState() == CONNECTED) + while(!shouldStop() && connectionState() == CONNECTED) { tick(); std::this_thread::sleep_for(std::chrono::milliseconds(200)); diff --git a/libretroshare/src/tor/TorControl.cpp b/libretroshare/src/tor/TorControl.cpp index d6d16355b..caf4576fa 100644 --- a/libretroshare/src/tor/TorControl.cpp +++ b/libretroshare/src/tor/TorControl.cpp @@ -46,8 +46,6 @@ #include "StrUtil.h" #include "PendingOperation.h" -Tor::TorControl *torControl = 0; - class nullstream: public std::ostream {}; static std::ostream& torctrldebug() @@ -70,6 +68,11 @@ TorControl::TorControl() mSocket = new TorControlSocket(this); } +TorControl::~TorControl() +{ + delete(mSocket); +} + static RsTorConnectivityStatus torConnectivityStatus(Tor::TorControl::Status t) { switch(t) diff --git a/libretroshare/src/tor/TorControl.h b/libretroshare/src/tor/TorControl.h index 941c088d2..568a1aaf2 100644 --- a/libretroshare/src/tor/TorControl.h +++ b/libretroshare/src/tor/TorControl.h @@ -68,6 +68,7 @@ public: }; explicit TorControl(); + virtual ~TorControl(); /* Information */ Status status() const; @@ -148,5 +149,3 @@ private: }; } - -extern Tor::TorControl *torControl; diff --git a/libretroshare/src/tor/TorManager.cpp b/libretroshare/src/tor/TorManager.cpp index dc1f6e116..bd768af68 100644 --- a/libretroshare/src/tor/TorManager.cpp +++ b/libretroshare/src/tor/TorManager.cpp @@ -71,6 +71,7 @@ public: HiddenService *hiddenService ; explicit TorManagerPrivate(TorManager *parent = 0); + virtual ~TorManagerPrivate(); std::string torExecutablePath() const; bool createDataDir(const std::string &path); @@ -94,6 +95,11 @@ TorManager::TorManager() { } +TorManager::~TorManager() +{ + delete(d); +} + TorManagerPrivate::TorManagerPrivate(TorManager *parent) : q(parent) , process(0) @@ -104,6 +110,11 @@ TorManagerPrivate::TorManagerPrivate(TorManager *parent) control->set_statusChanged_callback([this](int new_status,int /*old_status*/) { controlStatusChanged(new_status); }); } +TorManagerPrivate::~TorManagerPrivate() +{ + delete(control); +} + TorManager *TorManager::instance() { static TorManager *p = 0; diff --git a/libretroshare/src/tor/TorManager.h b/libretroshare/src/tor/TorManager.h index 5a62f6d00..a96370bc7 100644 --- a/libretroshare/src/tor/TorManager.h +++ b/libretroshare/src/tor/TorManager.h @@ -51,6 +51,7 @@ class TorManager : public HiddenServiceClient, public RsThread, public RsTor { public: static TorManager *instance(); + virtual ~TorManager(); TorProcess *process(); TorControl *control(); diff --git a/retroshare-gui/src/TorControl/TorControlWindow.cpp b/retroshare-gui/src/TorControl/TorControlWindow.cpp index f60e121f3..c369a6b12 100644 --- a/retroshare-gui/src/TorControl/TorControlWindow.cpp +++ b/retroshare-gui/src/TorControl/TorControlWindow.cpp @@ -51,6 +51,11 @@ TorControlDialog::TorControlDialog(QWidget *) adjustSize(); } +TorControlDialog::~TorControlDialog() +{ + rsEvents->unregisterEventsHandler(mEventHandlerId); +} + void TorControlDialog::handleEvent_main_thread(std::shared_ptr event) { if(event->mType != RsEventType::TOR_MANAGER) return; diff --git a/retroshare-gui/src/TorControl/TorControlWindow.h b/retroshare-gui/src/TorControl/TorControlWindow.h index 7dc8c8bda..412c08ed5 100644 --- a/retroshare-gui/src/TorControl/TorControlWindow.h +++ b/retroshare-gui/src/TorControl/TorControlWindow.h @@ -15,6 +15,7 @@ class TorControlDialog: public QWidget, public Ui::TorControlDialog public: TorControlDialog(QWidget *parent =NULL); + virtual ~TorControlDialog(); enum TorStatus { TOR_STATUS_UNKNOWN = 0x00,