aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2014-07-15 16:26:16 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2014-07-15 16:27:47 +0200
commit33357b27a0f6e344e760caf87e96b577b4c25ad7 (patch)
tree94d93c0701f25d22a1b205f79cb2fcde0a9091c7 /src
parentc715ff52c75398a3a65975f1d1b23834bd8426ee (diff)
downloadbitcoin-33357b27a0f6e344e760caf87e96b577b4c25ad7.tar.xz
qt: Start core thread only when needed
Start the core thread only when needed for initialization or shutdown. Avoids a bit of overhead, and also avoids spamming two log messages before logging is properly initialized.
Diffstat (limited to 'src')
-rw-r--r--src/qt/bitcoin.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp
index 6b1e50922e..43466663fa 100644
--- a/src/qt/bitcoin.cpp
+++ b/src/qt/bitcoin.cpp
@@ -286,15 +286,17 @@ BitcoinApplication::BitcoinApplication(int &argc, char **argv):
returnValue(0)
{
setQuitOnLastWindowClosed(false);
- startThread();
}
BitcoinApplication::~BitcoinApplication()
{
- qDebug() << __func__ << ": Stopping thread";
- emit stopThread();
- coreThread->wait();
- qDebug() << __func__ << ": Stopped thread";
+ if(coreThread)
+ {
+ qDebug() << __func__ << ": Stopping thread";
+ emit stopThread();
+ coreThread->wait();
+ qDebug() << __func__ << ": Stopped thread";
+ }
delete window;
window = 0;
@@ -337,6 +339,8 @@ void BitcoinApplication::createSplashScreen(bool isaTestNet)
void BitcoinApplication::startThread()
{
+ if(coreThread)
+ return;
coreThread = new QThread(this);
BitcoinCore *executor = new BitcoinCore();
executor->moveToThread(coreThread);
@@ -357,12 +361,14 @@ void BitcoinApplication::startThread()
void BitcoinApplication::requestInitialize()
{
qDebug() << __func__ << ": Requesting initialize";
+ startThread();
emit requestedInitialize();
}
void BitcoinApplication::requestShutdown()
{
qDebug() << __func__ << ": Requesting shutdown";
+ startThread();
window->hide();
window->setClientModel(0);
pollShutdownTimer->stop();