aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
authorPhilip Kaufmann <phil.kaufmann@t-online.de>2012-06-11 07:40:14 +0200
committerPhilip Kaufmann <phil.kaufmann@t-online.de>2012-06-12 07:21:03 +0200
commit9247134eaba9a1d0fa74f22de238af1476663005 (patch)
tree50a54aae174152f5a27f48c923d2124937331f43 /src/init.cpp
parent883a310904b3d36c9d74b887d47c14a072ebae7d (diff)
introduce a new StartShutdown() function, which starts a thread with Shutdown() if no GUI is used and calls uiInterface.QueueShutdown() if a GUI is used / all direct uiInterface.QueueShutdown() calls are replaced with Shutdown() - this ensures a clean GUI shutdown, even when catching a SIGTERM and allows the BitcoinGUI destructor to get called (which fixes a tray-icon issue and keeps the tray-icon until Bitcoin-Qt exits)
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/init.cpp b/src/init.cpp
index bf9551e858..08b594f56c 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -38,6 +38,17 @@ void ExitTimeout(void* parg)
#endif
}
+void StartShutdown()
+{
+#ifdef QT_GUI
+ // ensure we leave the Qt main loop for a clean GUI exit (Shutdown() is called in bitcoin.cpp afterwards)
+ uiInterface.QueueShutdown();
+#else
+ // Without UI, Shutdown() can simply be started in a new thread
+ CreateThread(Shutdown, NULL);
+#endif
+}
+
void Shutdown(void* parg)
{
static CCriticalSection cs_Shutdown;
@@ -66,7 +77,10 @@ void Shutdown(void* parg)
Sleep(50);
printf("Bitcoin exited\n\n");
fExit = true;
+#ifndef QT_GUI
+ // ensure non UI client get's exited here, but let Bitcoin-Qt reach return 0; in bitcoin.cpp
exit(0);
+#endif
}
else
{