diff options
author | Gavin Andresen <gavinandresen@gmail.com> | 2013-04-03 18:25:00 -0700 |
---|---|---|
committer | Gavin Andresen <gavinandresen@gmail.com> | 2013-04-03 18:25:00 -0700 |
commit | a0a437c86ae404152de883ac6a1463e6641eda1c (patch) | |
tree | e99240bd446613584b20c7b9762af5711bf3f7ff /src/qt/bitcoin.cpp | |
parent | 1c4f02139c03d0eedd52ebe0f886d44820402bf6 (diff) | |
parent | 723035bb6839c5d65bfee96d501a8c54814778e3 (diff) |
Merge pull request #2357 from gavinandresen/shutdowncleanup
Thread / shutdown cleanup
Diffstat (limited to 'src/qt/bitcoin.cpp')
-rw-r--r-- | src/qt/bitcoin.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index 2c47f30e92..f079f3b0e9 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -11,6 +11,7 @@ #include "guiutil.h" #include "guiconstants.h" #include "init.h" +#include "util.h" #include "ui_interface.h" #include "paymentserver.h" @@ -87,11 +88,6 @@ static void InitMessage(const std::string &message) printf("init message: %s\n", message.c_str()); } -static void QueueShutdown() -{ - QMetaObject::invokeMethod(qApp, "quit", Qt::QueuedConnection); -} - /* Translate string to current locale using Qt. */ @@ -185,7 +181,6 @@ int main(int argc, char *argv[]) uiInterface.ThreadSafeMessageBox.connect(ThreadSafeMessageBox); uiInterface.ThreadSafeAskFee.connect(ThreadSafeAskFee); uiInterface.InitMessage.connect(InitMessage); - uiInterface.QueueShutdown.connect(QueueShutdown); uiInterface.Translate.connect(Translate); // Show help message immediately after parsing command-line options (for "-lang") and setting locale, @@ -215,9 +210,16 @@ int main(int argc, char *argv[]) if (GUIUtil::GetStartOnSystemStartup()) GUIUtil::SetStartOnSystemStartup(true); + boost::thread_group threadGroup; + BitcoinGUI window; guiref = &window; - if(AppInit2()) + + QTimer* pollShutdownTimer = new QTimer(guiref); + QObject::connect(pollShutdownTimer, SIGNAL(timeout()), guiref, SLOT(detectShutdown())); + pollShutdownTimer->start(200); + + if(AppInit2(threadGroup)) { { // Put this in a block, so that the Model objects are cleaned up before @@ -258,7 +260,9 @@ int main(int argc, char *argv[]) guiref = 0; } // Shutdown the core and its threads, but don't exit Bitcoin-Qt here - Shutdown(NULL); + threadGroup.interrupt_all(); + threadGroup.join_all(); + Shutdown(); } else { |