summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Keller <rainer.keller@theqtcompany.com>2015-06-09 12:34:12 +0200
committerRainer Keller <rainer.keller@theqtcompany.com>2015-06-09 13:50:01 +0300
commit3804f0dc00471a209bb5d85ba3816c09af877109 (patch)
tree3607ea2f64068dde5f04376120d1cb4d7b6a5eef
parent2631768b484176836694ec4afdb81ef31886c142 (diff)
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 <laszlo.agocs@theqtcompany.com>
-rw-r--r--main.cpp11
-rw-r--r--process.cpp12
-rw-r--r--process.h1
3 files changed, 22 insertions, 2 deletions
diff --git a/main.cpp b/main.cpp
index 08be98c..63341fe 100644
--- a/main.cpp
+++ b/main.cpp
@@ -55,6 +55,7 @@ static void usage()
"--debug-gdb Start GDB debugging\n"
"--debug-qml Start QML debugging\n"
"--stop Stop already running application\n"
+ "--stop-for-restart Stop already running application and prepare to restart it\n"
"--launch Start application without stopping already running application\n"
"--show-platform Show platform information\n"
"--make-default Make this application the default on boot\n"
@@ -62,7 +63,7 @@ static void usage()
"--print-debug Print debug messages to stdout on Android\n"
"--version Print version information\n"
"--detach Start application as usual, then go into background\n"
- "--restart Restart the current running application\n"
+ "--restart Restart the current running application or an application stopped with --stop-for-restart\n"
"--help, -h, -help Show this help\n"
);
}
@@ -164,6 +165,11 @@ static void restart()
connectSocket("restart");
}
+static void stopForRestart()
+{
+ connectSocket("stopForRestart");
+}
+
static int openServer(QTcpServer *s, Utils::PortList &range)
{
while (range.hasMore()) {
@@ -375,6 +381,9 @@ int main(int argc, char **argv)
} else if (arg == "--restart") {
restart();
return 0;
+ } else if (arg == "--stop-for-restart") {
+ stopForRestart();
+ return 0;
} else if (arg == "--help" || arg == "-help" || arg == "-h") {
usage();
return 0;
diff --git a/process.cpp b/process.cpp
index 64bbc13..d3d8fdb 100644
--- a/process.cpp
+++ b/process.cpp
@@ -259,7 +259,8 @@ void Process::stop()
{
if (mProcess->state() == QProcess::QProcess::NotRunning) {
printf("No process running\n");
- qApp->exit();
+ if (!mBeingRestarted)
+ qApp->exit();
return;
}
@@ -276,6 +277,13 @@ void Process::stop()
mProcess->kill();
}
+void Process::stopForRestart()
+{
+ printf("Stopping application for restart\n");
+ mBeingRestarted = true;
+ stop();
+}
+
void Process::restart()
{
printf("Restarting application\n");
@@ -313,6 +321,8 @@ void Process::incomingConnection(int i)
stop();
else if (command == "restart")
restart();
+ else if (command == "stopForRestart")
+ stopForRestart();
else
stop();
}
diff --git a/process.h b/process.h
index 105d051..10fc13b 100644
--- a/process.h
+++ b/process.h
@@ -60,6 +60,7 @@ public:
void setStdoutFd(qintptr stdoutFd);
public slots:
void stop();
+ void stopForRestart();
void restart();
private slots:
void readyReadStandardError();