From ef30d2d3b64ea198a0508d5268656db13779d919 Mon Sep 17 00:00:00 2001 From: hypnosis-i2p Date: Fri, 8 Sep 2017 15:59:19 +0800 Subject: [PATCH] fixes #945 --- qt/i2pd_qt/ClientTunnelPane.cpp | 1 + qt/i2pd_qt/ServerTunnelPane.cpp | 1 + qt/i2pd_qt/TunnelPane.cpp | 4 ++++ qt/i2pd_qt/TunnelPane.h | 3 +++ qt/i2pd_qt/widgetlock.h | 4 +++- qt/i2pd_qt/widgetlockregistry.h | 16 ++++++++++------ 6 files changed, 22 insertions(+), 7 deletions(-) diff --git a/qt/i2pd_qt/ClientTunnelPane.cpp b/qt/i2pd_qt/ClientTunnelPane.cpp index 537abb1c..7f00cb31 100644 --- a/qt/i2pd_qt/ClientTunnelPane.cpp +++ b/qt/i2pd_qt/ClientTunnelPane.cpp @@ -11,6 +11,7 @@ void ClientTunnelPane::setGroupBoxTitle(const QString & title) { } void ClientTunnelPane::deleteClientTunnelForm() { + TunnelPane::deleteTunnelForm(); delete clientTunnelNameGroupBox; clientTunnelNameGroupBox=nullptr; diff --git a/qt/i2pd_qt/ServerTunnelPane.cpp b/qt/i2pd_qt/ServerTunnelPane.cpp index cc024386..827f6a37 100644 --- a/qt/i2pd_qt/ServerTunnelPane.cpp +++ b/qt/i2pd_qt/ServerTunnelPane.cpp @@ -266,6 +266,7 @@ int ServerTunnelPane::appendServerTunnelForm( } void ServerTunnelPane::deleteServerTunnelForm() { + TunnelPane::deleteTunnelForm(); delete serverTunnelNameGroupBox;//->deleteLater(); serverTunnelNameGroupBox=nullptr; diff --git a/qt/i2pd_qt/TunnelPane.cpp b/qt/i2pd_qt/TunnelPane.cpp index 84e8aed0..5f412070 100644 --- a/qt/i2pd_qt/TunnelPane.cpp +++ b/qt/i2pd_qt/TunnelPane.cpp @@ -218,3 +218,7 @@ QString TunnelPane::readTunnelTypeComboboxData() { i2p::data::SigningKeyType TunnelPane::readSigTypeComboboxUI(QComboBox* sigTypeComboBox) { return (i2p::data::SigningKeyType) sigTypeComboBox->currentData().toInt(); } + +void TunnelPane::deleteTunnelForm() { + widgetlocks.deleteListeners(); +} diff --git a/qt/i2pd_qt/TunnelPane.h b/qt/i2pd_qt/TunnelPane.h index f306e9dc..abf0b42d 100644 --- a/qt/i2pd_qt/TunnelPane.h +++ b/qt/i2pd_qt/TunnelPane.h @@ -31,6 +31,9 @@ public: TunnelPane(TunnelsPageUpdateListener* tunnelsPageUpdateListener_, TunnelConfig* tunconf); virtual ~TunnelPane(){} + void deleteTunnelForm(); + + virtual ServerTunnelPane* asServerTunnelPane()=0; virtual ClientTunnelPane* asClientTunnelPane()=0; diff --git a/qt/i2pd_qt/widgetlock.h b/qt/i2pd_qt/widgetlock.h index 513f328a..5b21125c 100644 --- a/qt/i2pd_qt/widgetlock.h +++ b/qt/i2pd_qt/widgetlock.h @@ -12,6 +12,7 @@ class widgetlock : public QObject { private: QWidget* widget; QPushButton* lockButton; + public slots: void lockButtonClicked(bool) { bool wasEnabled = widget->isEnabled(); @@ -25,7 +26,8 @@ public: lockButton->setText(lockButton->tr("Edit")); QObject::connect(lockButton,SIGNAL(clicked(bool)), this, SLOT(lockButtonClicked(bool))); } - virtual ~widgetlock() { + virtual ~widgetlock() {} + void deleteListener() { QObject::disconnect(lockButton,SIGNAL(clicked(bool)), this, SLOT(lockButtonClicked(bool))); } }; diff --git a/qt/i2pd_qt/widgetlockregistry.h b/qt/i2pd_qt/widgetlockregistry.h index 1091af43..78ee142a 100644 --- a/qt/i2pd_qt/widgetlockregistry.h +++ b/qt/i2pd_qt/widgetlockregistry.h @@ -9,15 +9,19 @@ class widgetlockregistry { public: widgetlockregistry() : locks() {} - virtual ~widgetlockregistry() { - while(!locks.empty()) { - delete locks.back(); - locks.pop_back(); - } - } + virtual ~widgetlockregistry() {} void add(widgetlock* lock) { locks.push_back(lock); } + + void deleteListeners() { + while(!locks.empty()) { + widgetlock* lock = locks.back(); + lock->deleteListener(); + delete lock; + locks.pop_back(); + } + } }; #endif // WIDGETLOCKREGISTRY_H