Merge #9834: qt: clean up initialize/shutdown signals

5b528d7 qt: clean up initialize/shutdown signals (Marko Bencun)

Tree-SHA512: 4a8326ba05a1cc037203a7abe01d4e77b6ff83e62ec14f09834ada4b35a23ffb1f28b5587aa2e02601f0f6c7d62c5647a7f10320239b4bac132791be29930ddb
This commit is contained in:
Jonas Schnelli 2017-03-02 09:37:37 +01:00
commit b00ba6251f
No known key found for this signature in database
GPG Key ID: 1EB776BB03C7922D

View File

@ -178,8 +178,8 @@ public Q_SLOTS:
void shutdown(); void shutdown();
Q_SIGNALS: Q_SIGNALS:
void initializeResult(int retval); void initializeResult(bool success);
void shutdownResult(int retval); void shutdownResult();
void runawayException(const QString &message); void runawayException(const QString &message);
private: private:
@ -223,8 +223,8 @@ public:
WId getMainWinId() const; WId getMainWinId() const;
public Q_SLOTS: public Q_SLOTS:
void initializeResult(int retval); void initializeResult(bool success);
void shutdownResult(int retval); void shutdownResult();
/// Handle runaway exceptions. Shows a message box with the problem and quits the program. /// Handle runaway exceptions. Shows a message box with the problem and quits the program.
void handleRunawayException(const QString &message); void handleRunawayException(const QString &message);
@ -284,7 +284,7 @@ void BitcoinCore::initialize()
Q_EMIT initializeResult(false); Q_EMIT initializeResult(false);
return; return;
} }
int rv = AppInitMain(threadGroup, scheduler); bool rv = AppInitMain(threadGroup, scheduler);
Q_EMIT initializeResult(rv); Q_EMIT initializeResult(rv);
} catch (const std::exception& e) { } catch (const std::exception& e) {
handleRunawayException(&e); handleRunawayException(&e);
@ -302,7 +302,7 @@ void BitcoinCore::shutdown()
threadGroup.join_all(); threadGroup.join_all();
Shutdown(); Shutdown();
qDebug() << __func__ << ": Shutdown finished"; qDebug() << __func__ << ": Shutdown finished";
Q_EMIT shutdownResult(1); Q_EMIT shutdownResult();
} catch (const std::exception& e) { } catch (const std::exception& e) {
handleRunawayException(&e); handleRunawayException(&e);
} catch (...) { } catch (...) {
@ -398,8 +398,8 @@ void BitcoinApplication::startThread()
executor->moveToThread(coreThread); executor->moveToThread(coreThread);
/* communication to and from thread */ /* communication to and from thread */
connect(executor, SIGNAL(initializeResult(int)), this, SLOT(initializeResult(int))); connect(executor, SIGNAL(initializeResult(bool)), this, SLOT(initializeResult(bool)));
connect(executor, SIGNAL(shutdownResult(int)), this, SLOT(shutdownResult(int))); connect(executor, SIGNAL(shutdownResult()), this, SLOT(shutdownResult()));
connect(executor, SIGNAL(runawayException(QString)), this, SLOT(handleRunawayException(QString))); connect(executor, SIGNAL(runawayException(QString)), this, SLOT(handleRunawayException(QString)));
connect(this, SIGNAL(requestedInitialize()), executor, SLOT(initialize())); connect(this, SIGNAL(requestedInitialize()), executor, SLOT(initialize()));
connect(this, SIGNAL(requestedShutdown()), executor, SLOT(shutdown())); connect(this, SIGNAL(requestedShutdown()), executor, SLOT(shutdown()));
@ -450,12 +450,12 @@ void BitcoinApplication::requestShutdown()
Q_EMIT requestedShutdown(); Q_EMIT requestedShutdown();
} }
void BitcoinApplication::initializeResult(int retval) void BitcoinApplication::initializeResult(bool success)
{ {
qDebug() << __func__ << ": Initialization result: " << retval; qDebug() << __func__ << ": Initialization result: " << success;
// Set exit result: 0 if successful, 1 if failure // Set exit result.
returnValue = retval ? 0 : 1; returnValue = success ? EXIT_SUCCESS : EXIT_FAILURE;
if(retval) if(success)
{ {
// Log this only after AppInitMain finishes, as then logging setup is guaranteed complete // Log this only after AppInitMain finishes, as then logging setup is guaranteed complete
qWarning() << "Platform customization:" << platformStyle->getName(); qWarning() << "Platform customization:" << platformStyle->getName();
@ -507,9 +507,8 @@ void BitcoinApplication::initializeResult(int retval)
} }
} }
void BitcoinApplication::shutdownResult(int retval) void BitcoinApplication::shutdownResult()
{ {
qDebug() << __func__ << ": Shutdown result: " << retval;
quit(); // Exit main loop after shutdown finished quit(); // Exit main loop after shutdown finished
} }