aboutsummaryrefslogtreecommitdiff
path: root/src/qt
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2013-03-23 18:14:12 -0400
committerGavin Andresen <gavinandresen@gmail.com>2013-04-03 19:58:47 -0400
commit723035bb6839c5d65bfee96d501a8c54814778e3 (patch)
treed0d80686edc2c25446fcb0a67d68c8c12722f935 /src/qt
parentb31499ec72edd1554d4612d1b54808fce0360e14 (diff)
Have Qt poll for shutdown requested, the QT way.
Diffstat (limited to 'src/qt')
-rw-r--r--src/qt/bitcoin.cpp12
-rw-r--r--src/qt/bitcoingui.cpp7
-rw-r--r--src/qt/bitcoingui.h3
3 files changed, 16 insertions, 6 deletions
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp
index b61921fca0..f079f3b0e9 100644
--- a/src/qt/bitcoin.cpp
+++ b/src/qt/bitcoin.cpp
@@ -88,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.
*/
@@ -186,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,
@@ -217,8 +211,14 @@ int main(int argc, char *argv[])
GUIUtil::SetStartOnSystemStartup(true);
boost::thread_group threadGroup;
+
BitcoinGUI window;
guiref = &window;
+
+ QTimer* pollShutdownTimer = new QTimer(guiref);
+ QObject::connect(pollShutdownTimer, SIGNAL(timeout()), guiref, SLOT(detectShutdown()));
+ pollShutdownTimer->start(200);
+
if(AppInit2(threadGroup))
{
{
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index adc6cd4742..9da5b85006 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -24,6 +24,7 @@
#include "rpcconsole.h"
#include "ui_interface.h"
#include "wallet.h"
+#include "init.h"
#ifdef Q_OS_MAC
#include "macdockiconhandler.h"
@@ -839,3 +840,9 @@ void BitcoinGUI::toggleHidden()
{
showNormalIfMinimized(true);
}
+
+void BitcoinGUI::detectShutdown()
+{
+ if (ShutdownRequested())
+ QMetaObject::invokeMethod(QCoreApplication::instance(), "quit", Qt::QueuedConnection);
+}
diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h
index 8f44389fd2..aba81cb3bc 100644
--- a/src/qt/bitcoingui.h
+++ b/src/qt/bitcoingui.h
@@ -199,6 +199,9 @@ private slots:
void showNormalIfMinimized(bool fToggleHidden = false);
/** Simply calls showNormalIfMinimized(true) for use in SLOT() macro */
void toggleHidden();
+
+ /** called by a timer to check if fRequestShutdown has been set **/
+ void detectShutdown();
};
#endif // BITCOINGUI_H