qt: clean up initialize/shutdown signals
- Change initializeResult(int) to initializeResult(bool) to avoid implicit type conversion. - Use EXIT_FAILURE and EXIT_SUCCESS instead of magic numbers. - Remove the argument from shutdownResult(int); it was called with a constant argument.
This commit is contained in:
parent
bed5b30a56
commit
5b528d746c
1 changed files with 14 additions and 15 deletions
|
@ -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 AppInit2 finishes, as then logging setup is guaranteed complete
|
// Log this only after AppInit2 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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue