diff options
author | Rainer Keller <rainer.keller@theqtcompany.com> | 2015-06-09 12:34:12 +0200 |
---|---|---|
committer | Rainer Keller <rainer.keller@theqtcompany.com> | 2015-06-09 13:50:01 +0300 |
commit | 3804f0dc00471a209bb5d85ba3816c09af877109 (patch) | |
tree | 3607ea2f64068dde5f04376120d1cb4d7b6a5eef | |
parent | 2631768b484176836694ec4afdb81ef31886c142 (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.cpp | 11 | ||||
-rw-r--r-- | process.cpp | 12 | ||||
-rw-r--r-- | process.h | 1 |
3 files changed, 22 insertions, 2 deletions
@@ -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(); } @@ -60,6 +60,7 @@ public: void setStdoutFd(qintptr stdoutFd); public slots: void stop(); + void stopForRestart(); void restart(); private slots: void readyReadStandardError(); |