Skip to content

Commit f18d406

Browse files
committed
fixed memory leak in the execute process code
1 parent 990c12b commit f18d406

File tree

5 files changed

+18
-11
lines changed

5 files changed

+18
-11
lines changed

apps/cmstapp/code/control_box/controlbox.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ DEALINGS IN THE SOFTWARE.
7070
# include "./code/vpn_prov_ed/vpn_ed.h"
7171
# include "./code/trstring/tr_strings.h"
7272
# include "./code/shared/shared.h"
73-
# include "./code/gen_conf_ed/gen_conf_ed.h"
7473

7574
// headers for system logging
7675
# include <stdio.h>
@@ -162,7 +161,8 @@ ControlBox::ControlBox(const QCommandLineParser& parser, QWidget *parent)
162161
trayiconbackground = QColor();
163162
trayicon = new QSystemTrayIcon(this);
164163
f_connmanversion = 0.0;
165-
164+
gened = NULL;
165+
proc = NULL;
166166
iconman = new IconManager(this);
167167

168168
// set a stylesheet on the tab widget - used to hide disabled tabs
@@ -740,7 +740,7 @@ void ControlBox::connectPressed()
740740
return;
741741
}
742742

743-
//Because of single selection mode list can only have 0 or 1 items in it.
743+
//Because of single selection mode list can only have 0 or 1 items in it.
744744
if (qtw == ui.tableWidget_wifi) pendingobjectpath = wifi_list.at(list.at(0)->row()).objpath.path();
745745
else if (qtw == ui.tableWidget_vpn) pendingobjectpath = vpn_list.at(list.at(0)->row()).objpath.path();
746746
else pendingobjectpath.clear();
@@ -754,18 +754,16 @@ void ControlBox::connectPressed()
754754
QString cmd = args.first();
755755
args.removeFirst();
756756
if (ui.checkBox_modifyservicefile->isChecked()) {
757-
GEN_Editor* gened = new GEN_Editor(this);
757+
gened = new GEN_Editor(this);
758758
gened->editInPlace(ui.comboBox_beforeconnectservicefile->currentText(), cmd, args);
759759
connect (gened, SIGNAL(finished(int)), this, SLOT(requestConnection()));
760-
// gened->deleteLater();
761760
} // program does require a root helper
762761
else {
763-
QProcess* proc = new QProcess(this);
764-
proc->startDetached(cmd, args);
762+
proc = new QProcess(this);
763+
proc->start(cmd, args);
765764
connect (proc, SIGNAL(finished(int)), this, SLOT(requestConnection()));
766-
// proc->deleteLater();
767765
} // program does not require root helper
768-
} // if service is correct
766+
} // if selected service matches the one to modify
769767
} // if there is a command to execute
770768

771769
// else request the connection now
@@ -777,6 +775,11 @@ void ControlBox::connectPressed()
777775
//
778776
// Slot to actually request a connection via DBUS. Called from the connectPressed() slot
779777
void ControlBox::requestConnection() {
778+
// only way here is when a finished() signal fires, delete the object that did it
779+
if (proc) delete proc;
780+
if (gened) delete gened;
781+
782+
// data member
780783
QDBusInterface* iface_serv = NULL;
781784

782785
iface_serv = new QDBusInterface(DBUS_CON_SERVICE, pendingobjectpath, "net.connman.Service", QDBusConnection::systemBus(), this);

apps/cmstapp/code/control_box/controlbox.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ DEALINGS IN THE SOFTWARE.
5555
# include "./code/notify/notify.h"
5656
# include "./code/iconman/iconman.h"
5757
# include "./code/vpn_agent/vpnagent.h"
58+
# include "./code/gen_conf_ed/gen_conf_ed.h"
5859

5960
// Two of the connman.Manager query functions will return an array of structures.
6061
// This struct provides a receiving element we can use to collect the return data.
@@ -149,6 +150,8 @@ class ControlBox : public QDialog
149150
QColor trayiconbackground;
150151
IconManager* iconman;
151152
float f_connmanversion;
153+
GEN_Editor* gened;
154+
QProcess* proc;
152155

153156
// functions
154157
int managerRescan(const int& srv = 0);

apps/cmstapp/code/gen_conf_ed/gen_conf_ed.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ GEN_Editor::GEN_Editor(QWidget* parent) : QWidget(parent)
5555
path.clear();
5656
process.clear();
5757
args.clear();
58-
filecontents.clear();\
58+
filecontents.clear();
5959
proc = NULL;
6060

6161
// signals and slots

apps/resource.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ DEALINGS IN THE SOFTWARE.
3535
///////////////////////////////// Program Values ///////////////////////
3636
//
3737
// Program Info (may be visible, but don't mark for tranalation)
38-
#define VERSION "2020.03.23-1"
38+
#define VERSION "2020.03.24-1"
3939

4040
#define RELEASE_DATE "7 March 2020"
4141
#define COPYRIGHT_DATE "2013-2020"

text/changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<li>Fixed update problems in details tab.</li>
99
<li>Fixed VPN tray icon not always showing (possibly issue #198).</li>
1010
<li>Fixed notification daemon working and starting.</li>
11+
<li>Added ability to execute a process prior to making a wifi or vpn connection.</li>
1112
</ul>
1213
<b> 2020.03.07</b>
1314
<ul>

0 commit comments

Comments
 (0)