From f18d4068f932a6277a19c2b443333018d62c0345 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 24 Mar 2020 20:03:34 -0400 Subject: [PATCH] fixed memory leak in the execute process code --- apps/cmstapp/code/control_box/controlbox.cpp | 21 +++++++++++-------- apps/cmstapp/code/control_box/controlbox.h | 3 +++ apps/cmstapp/code/gen_conf_ed/gen_conf_ed.cpp | 2 +- apps/resource.h | 2 +- text/changelog.txt | 1 + 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/apps/cmstapp/code/control_box/controlbox.cpp b/apps/cmstapp/code/control_box/controlbox.cpp index 01da668d..3e1507d4 100755 --- a/apps/cmstapp/code/control_box/controlbox.cpp +++ b/apps/cmstapp/code/control_box/controlbox.cpp @@ -70,7 +70,6 @@ DEALINGS IN THE SOFTWARE. # include "./code/vpn_prov_ed/vpn_ed.h" # include "./code/trstring/tr_strings.h" # include "./code/shared/shared.h" -# include "./code/gen_conf_ed/gen_conf_ed.h" // headers for system logging # include @@ -162,7 +161,8 @@ ControlBox::ControlBox(const QCommandLineParser& parser, QWidget *parent) trayiconbackground = QColor(); trayicon = new QSystemTrayIcon(this); f_connmanversion = 0.0; - + gened = NULL; + proc = NULL; iconman = new IconManager(this); // set a stylesheet on the tab widget - used to hide disabled tabs @@ -740,7 +740,7 @@ void ControlBox::connectPressed() return; } -//Because of single selection mode list can only have 0 or 1 items in it. + //Because of single selection mode list can only have 0 or 1 items in it. if (qtw == ui.tableWidget_wifi) pendingobjectpath = wifi_list.at(list.at(0)->row()).objpath.path(); else if (qtw == ui.tableWidget_vpn) pendingobjectpath = vpn_list.at(list.at(0)->row()).objpath.path(); else pendingobjectpath.clear(); @@ -754,18 +754,16 @@ void ControlBox::connectPressed() QString cmd = args.first(); args.removeFirst(); if (ui.checkBox_modifyservicefile->isChecked()) { - GEN_Editor* gened = new GEN_Editor(this); + gened = new GEN_Editor(this); gened->editInPlace(ui.comboBox_beforeconnectservicefile->currentText(), cmd, args); connect (gened, SIGNAL(finished(int)), this, SLOT(requestConnection())); -// gened->deleteLater(); } // program does require a root helper else { - QProcess* proc = new QProcess(this); - proc->startDetached(cmd, args); + proc = new QProcess(this); + proc->start(cmd, args); connect (proc, SIGNAL(finished(int)), this, SLOT(requestConnection())); -// proc->deleteLater(); } // program does not require root helper - } // if service is correct + } // if selected service matches the one to modify } // if there is a command to execute // else request the connection now @@ -777,6 +775,11 @@ void ControlBox::connectPressed() // // Slot to actually request a connection via DBUS. Called from the connectPressed() slot void ControlBox::requestConnection() { + // only way here is when a finished() signal fires, delete the object that did it + if (proc) delete proc; + if (gened) delete gened; + + // data member QDBusInterface* iface_serv = NULL; iface_serv = new QDBusInterface(DBUS_CON_SERVICE, pendingobjectpath, "net.connman.Service", QDBusConnection::systemBus(), this); diff --git a/apps/cmstapp/code/control_box/controlbox.h b/apps/cmstapp/code/control_box/controlbox.h index 62841fa4..f3ab335f 100755 --- a/apps/cmstapp/code/control_box/controlbox.h +++ b/apps/cmstapp/code/control_box/controlbox.h @@ -55,6 +55,7 @@ DEALINGS IN THE SOFTWARE. # include "./code/notify/notify.h" # include "./code/iconman/iconman.h" # include "./code/vpn_agent/vpnagent.h" +# include "./code/gen_conf_ed/gen_conf_ed.h" // Two of the connman.Manager query functions will return an array of structures. // This struct provides a receiving element we can use to collect the return data. @@ -149,6 +150,8 @@ class ControlBox : public QDialog QColor trayiconbackground; IconManager* iconman; float f_connmanversion; + GEN_Editor* gened; + QProcess* proc; // functions int managerRescan(const int& srv = 0); diff --git a/apps/cmstapp/code/gen_conf_ed/gen_conf_ed.cpp b/apps/cmstapp/code/gen_conf_ed/gen_conf_ed.cpp index 979cc971..34963e9a 100644 --- a/apps/cmstapp/code/gen_conf_ed/gen_conf_ed.cpp +++ b/apps/cmstapp/code/gen_conf_ed/gen_conf_ed.cpp @@ -55,7 +55,7 @@ GEN_Editor::GEN_Editor(QWidget* parent) : QWidget(parent) path.clear(); process.clear(); args.clear(); - filecontents.clear();\ + filecontents.clear(); proc = NULL; // signals and slots diff --git a/apps/resource.h b/apps/resource.h index f3028ad0..f4a89611 100755 --- a/apps/resource.h +++ b/apps/resource.h @@ -35,7 +35,7 @@ DEALINGS IN THE SOFTWARE. ///////////////////////////////// Program Values /////////////////////// // // Program Info (may be visible, but don't mark for tranalation) -#define VERSION "2020.03.23-1" +#define VERSION "2020.03.24-1" #define RELEASE_DATE "7 March 2020" #define COPYRIGHT_DATE "2013-2020" diff --git a/text/changelog.txt b/text/changelog.txt index 9650b1d4..bc3bf36e 100644 --- a/text/changelog.txt +++ b/text/changelog.txt @@ -8,6 +8,7 @@
  • Fixed update problems in details tab.
  • Fixed VPN tray icon not always showing (possibly issue #198).
  • Fixed notification daemon working and starting.
  • +
  • Added ability to execute a process prior to making a wifi or vpn connection.
  • 2020.03.07