34
34
35
35
#include < boost/filesystem/operations.hpp>
36
36
#include < QApplication>
37
+ #include < QDebug>
37
38
#include < QLibraryInfo>
38
39
#include < QLocale>
39
40
#include < QMessageBox>
@@ -237,7 +238,7 @@ void BitcoinCore::initialize()
237
238
{
238
239
try
239
240
{
240
- LogPrintf ( " Running AppInit2 in thread\n " ) ;
241
+ qDebug () << __func__ << " : Running AppInit2 in thread" ;
241
242
int rv = AppInit2 (threadGroup);
242
243
if (rv)
243
244
{
@@ -258,11 +259,11 @@ void BitcoinCore::shutdown()
258
259
{
259
260
try
260
261
{
261
- LogPrintf ( " Running Shutdown in thread\n " ) ;
262
+ qDebug () << __func__ << " : Running Shutdown in thread" ;
262
263
threadGroup.interrupt_all ();
263
264
threadGroup.join_all ();
264
265
Shutdown ();
265
- LogPrintf ( " Shutdown finished\n " ) ;
266
+ qDebug () << __func__ << " : Shutdown finished" ;
266
267
emit shutdownResult (1 );
267
268
} catch (std::exception& e) {
268
269
handleRunawayException (&e);
@@ -285,15 +286,17 @@ BitcoinApplication::BitcoinApplication(int &argc, char **argv):
285
286
returnValue (0 )
286
287
{
287
288
setQuitOnLastWindowClosed (false );
288
- startThread ();
289
289
}
290
290
291
291
BitcoinApplication::~BitcoinApplication ()
292
292
{
293
- LogPrintf (" Stopping thread\n " );
294
- emit stopThread ();
295
- coreThread->wait ();
296
- LogPrintf (" Stopped thread\n " );
293
+ if (coreThread)
294
+ {
295
+ qDebug () << __func__ << " : Stopping thread" ;
296
+ emit stopThread ();
297
+ coreThread->wait ();
298
+ qDebug () << __func__ << " : Stopped thread" ;
299
+ }
297
300
298
301
delete window;
299
302
window = 0 ;
@@ -336,6 +339,8 @@ void BitcoinApplication::createSplashScreen(bool isaTestNet)
336
339
337
340
void BitcoinApplication::startThread ()
338
341
{
342
+ if (coreThread)
343
+ return ;
339
344
coreThread = new QThread (this );
340
345
BitcoinCore *executor = new BitcoinCore ();
341
346
executor->moveToThread (coreThread);
@@ -355,13 +360,15 @@ void BitcoinApplication::startThread()
355
360
356
361
void BitcoinApplication::requestInitialize ()
357
362
{
358
- LogPrintf (" Requesting initialize\n " );
363
+ qDebug () << __func__ << " : Requesting initialize" ;
364
+ startThread ();
359
365
emit requestedInitialize ();
360
366
}
361
367
362
368
void BitcoinApplication::requestShutdown ()
363
369
{
364
- LogPrintf (" Requesting shutdown\n " );
370
+ qDebug () << __func__ << " : Requesting shutdown" ;
371
+ startThread ();
365
372
window->hide ();
366
373
window->setClientModel (0 );
367
374
pollShutdownTimer->stop ();
@@ -383,7 +390,7 @@ void BitcoinApplication::requestShutdown()
383
390
384
391
void BitcoinApplication::initializeResult (int retval)
385
392
{
386
- LogPrintf ( " Initialization result: %i \n " , retval) ;
393
+ qDebug () << __func__ << " : Initialization result: " << retval;
387
394
// Set exit result: 0 if successful, 1 if failure
388
395
returnValue = retval ? 0 : 1 ;
389
396
if (retval)
@@ -438,7 +445,7 @@ void BitcoinApplication::initializeResult(int retval)
438
445
439
446
void BitcoinApplication::shutdownResult (int retval)
440
447
{
441
- LogPrintf ( " Shutdown result: %i \n " , retval) ;
448
+ qDebug () << __func__ << " : Shutdown result: " << retval;
442
449
quit (); // Exit main loop after shutdown finished
443
450
}
444
451
0 commit comments