Skip to content

Commit

Permalink
fixed memory leak in the execute process code
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-bibb committed Mar 25, 2020
1 parent 990c12b commit f18d406
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
21 changes: 12 additions & 9 deletions apps/cmstapp/code/control_box/controlbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stdio.h>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand All @@ -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
Expand All @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions apps/cmstapp/code/control_box/controlbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion apps/cmstapp/code/gen_conf_ed/gen_conf_ed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion apps/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions text/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<li>Fixed update problems in details tab.</li>
<li>Fixed VPN tray icon not always showing (possibly issue #198).</li>
<li>Fixed notification daemon working and starting.</li>
<li>Added ability to execute a process prior to making a wifi or vpn connection.</li>
</ul>
<b> 2020.03.07</b>
<ul>
Expand Down

0 comments on commit f18d406

Please sign in to comment.