Skip to content

Commit 3804f0d

Browse files
author
Rainer Keller
committed
Make appcontroller a temporary daemon
For a restart being successful the application has to be shut down with out terminating the appcontroller. Afterwards the appcontroller will be able to start the application again. Change-Id: I38fd0aded176a10dac40c419b6866ce70ec1fcef Reviewed-by: Laszlo Agocs <[email protected]>
1 parent 2631768 commit 3804f0d

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

main.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,15 @@ static void usage()
5555
"--debug-gdb Start GDB debugging\n"
5656
"--debug-qml Start QML debugging\n"
5757
"--stop Stop already running application\n"
58+
"--stop-for-restart Stop already running application and prepare to restart it\n"
5859
"--launch Start application without stopping already running application\n"
5960
"--show-platform Show platform information\n"
6061
"--make-default Make this application the default on boot\n"
6162
"--remove-default Restore the default application\n"
6263
"--print-debug Print debug messages to stdout on Android\n"
6364
"--version Print version information\n"
6465
"--detach Start application as usual, then go into background\n"
65-
"--restart Restart the current running application\n"
66+
"--restart Restart the current running application or an application stopped with --stop-for-restart\n"
6667
"--help, -h, -help Show this help\n"
6768
);
6869
}
@@ -164,6 +165,11 @@ static void restart()
164165
connectSocket("restart");
165166
}
166167

168+
static void stopForRestart()
169+
{
170+
connectSocket("stopForRestart");
171+
}
172+
167173
static int openServer(QTcpServer *s, Utils::PortList &range)
168174
{
169175
while (range.hasMore()) {
@@ -375,6 +381,9 @@ int main(int argc, char **argv)
375381
} else if (arg == "--restart") {
376382
restart();
377383
return 0;
384+
} else if (arg == "--stop-for-restart") {
385+
stopForRestart();
386+
return 0;
378387
} else if (arg == "--help" || arg == "-help" || arg == "-h") {
379388
usage();
380389
return 0;

process.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@ void Process::stop()
259259
{
260260
if (mProcess->state() == QProcess::QProcess::NotRunning) {
261261
printf("No process running\n");
262-
qApp->exit();
262+
if (!mBeingRestarted)
263+
qApp->exit();
263264
return;
264265
}
265266

@@ -276,6 +277,13 @@ void Process::stop()
276277
mProcess->kill();
277278
}
278279

280+
void Process::stopForRestart()
281+
{
282+
printf("Stopping application for restart\n");
283+
mBeingRestarted = true;
284+
stop();
285+
}
286+
279287
void Process::restart()
280288
{
281289
printf("Restarting application\n");
@@ -313,6 +321,8 @@ void Process::incomingConnection(int i)
313321
stop();
314322
else if (command == "restart")
315323
restart();
324+
else if (command == "stopForRestart")
325+
stopForRestart();
316326
else
317327
stop();
318328
}

process.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class Process : public QObject
6060
void setStdoutFd(qintptr stdoutFd);
6161
public slots:
6262
void stop();
63+
void stopForRestart();
6364
void restart();
6465
private slots:
6566
void readyReadStandardError();

0 commit comments

Comments
 (0)