Changeset View
Changeset View
Standalone View
Standalone View
src/qt/bitcoin.cpp
Show First 20 Lines • Show All 163 Lines • ▼ Show 20 Lines | |||||
* Class encapsulating Bitcoin ABC startup and shutdown. | * Class encapsulating Bitcoin ABC startup and shutdown. | ||||
* Allows running startup and shutdown in a different thread from the UI thread. | * Allows running startup and shutdown in a different thread from the UI thread. | ||||
*/ | */ | ||||
class BitcoinABC : public QObject { | class BitcoinABC : public QObject { | ||||
Q_OBJECT | Q_OBJECT | ||||
public: | public: | ||||
explicit BitcoinABC(); | explicit BitcoinABC(); | ||||
/** | |||||
* Basic initialization, before starting initialization/shutdown thread. | |||||
* Return true on success. | |||||
*/ | |||||
static bool baseInitialize(Config &config, RPCServer &rpcServer); | |||||
public Q_SLOTS: | public Q_SLOTS: | ||||
void initialize(Config *config, | void initialize(Config *config, | ||||
HTTPRPCRequestProcessor *httpRPCRequestProcessor, | HTTPRPCRequestProcessor *httpRPCRequestProcessor, | ||||
RPCServer *rpcServer); | RPCServer *rpcServer); | ||||
void shutdown(); | void shutdown(); | ||||
Q_SIGNALS: | Q_SIGNALS: | ||||
void initializeResult(bool success); | void initializeResult(bool success); | ||||
▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | |||||
BitcoinABC::BitcoinABC() : QObject() {} | BitcoinABC::BitcoinABC() : QObject() {} | ||||
void BitcoinABC::handleRunawayException(const std::exception *e) { | void BitcoinABC::handleRunawayException(const std::exception *e) { | ||||
PrintExceptionContinue(e, "Runaway exception"); | PrintExceptionContinue(e, "Runaway exception"); | ||||
Q_EMIT runawayException(QString::fromStdString(GetWarnings("gui"))); | Q_EMIT runawayException(QString::fromStdString(GetWarnings("gui"))); | ||||
} | } | ||||
void BitcoinABC::initialize(Config *cfg, | bool BitcoinABC::baseInitialize(Config &config, RPCServer &rpcServer) { | ||||
HTTPRPCRequestProcessor *httpRPCRequestProcessor, | |||||
RPCServer *rpcSrv) { | |||||
Config &config(*cfg); | |||||
RPCServer &rpcServer = *rpcSrv; | |||||
try { | |||||
qDebug() << __func__ << ": Running AppInit2 in thread"; | |||||
if (!AppInitBasicSetup()) { | if (!AppInitBasicSetup()) { | ||||
Q_EMIT initializeResult(false); | return false; | ||||
return; | |||||
} | } | ||||
if (!AppInitParameterInteraction(config, rpcServer)) { | if (!AppInitParameterInteraction(config, rpcServer)) { | ||||
Q_EMIT initializeResult(false); | return false; | ||||
return; | |||||
} | } | ||||
if (!AppInitSanityChecks()) { | if (!AppInitSanityChecks()) { | ||||
Q_EMIT initializeResult(false); | return false; | ||||
return; | } | ||||
if (!AppInitLockDataDirectory()) { | |||||
return false; | |||||
} | |||||
return true; | |||||
} | } | ||||
void BitcoinABC::initialize(Config *cfg, | |||||
HTTPRPCRequestProcessor *httpRPCRequestProcessor, | |||||
RPCServer *rpcSrv) { | |||||
Config &config(*cfg); | |||||
RPCServer &rpcServer = *rpcSrv; | |||||
try { | |||||
qDebug() << __func__ << ": Running initialization in thread"; | |||||
bool rv = AppInitMain(config, *httpRPCRequestProcessor, threadGroup, | bool rv = AppInitMain(config, *httpRPCRequestProcessor, threadGroup, | ||||
scheduler); | scheduler); | ||||
Q_EMIT initializeResult(rv); | Q_EMIT initializeResult(rv); | ||||
} catch (const std::exception &e) { | } catch (const std::exception &e) { | ||||
handleRunawayException(&e); | handleRunawayException(&e); | ||||
} catch (...) { | } catch (...) { | ||||
handleRunawayException(nullptr); | handleRunawayException(nullptr); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 467 Lines • ▼ Show 20 Lines | if (gArgs.GetBoolArg("-splash", DEFAULT_SPLASHSCREEN) && | ||||
!gArgs.GetBoolArg("-min", false)) | !gArgs.GetBoolArg("-min", false)) | ||||
app.createSplashScreen(networkStyle.data()); | app.createSplashScreen(networkStyle.data()); | ||||
RPCServer rpcServer; | RPCServer rpcServer; | ||||
HTTPRPCRequestProcessor httpRPCRequestProcessor(config, rpcServer); | HTTPRPCRequestProcessor httpRPCRequestProcessor(config, rpcServer); | ||||
try { | try { | ||||
app.createWindow(&config, networkStyle.data()); | app.createWindow(&config, networkStyle.data()); | ||||
// Perform base initialization before spinning up | |||||
// initialization/shutdown thread. This is acceptable because this | |||||
// function only contains steps that are quick to execute, so the GUI | |||||
// thread won't be held up. | |||||
if (BitcoinABC::baseInitialize(config, rpcServer)) { | |||||
app.requestInitialize(config, httpRPCRequestProcessor, rpcServer); | app.requestInitialize(config, httpRPCRequestProcessor, rpcServer); | ||||
#if defined(Q_OS_WIN) | #if defined(Q_OS_WIN) && QT_VERSION >= 0x050000 | ||||
deadalnix: Remove. We don't support older version of Qt. | |||||
WinShutdownMonitor::registerShutdownBlockReason( | WinShutdownMonitor::registerShutdownBlockReason( | ||||
QObject::tr("%1 didn't yet exit safely...") | QObject::tr("%1 didn't yet exit safely...") | ||||
.arg(QObject::tr(PACKAGE_NAME)), | .arg(QObject::tr(PACKAGE_NAME)), | ||||
(HWND)app.getMainWinId()); | (HWND)app.getMainWinId()); | ||||
#endif | #endif | ||||
app.exec(); | app.exec(); | ||||
app.requestShutdown(config); | app.requestShutdown(); | ||||
deadalnixUnsubmitted Not Done Inline ActionsRevert deadalnix: Revert | |||||
app.exec(); | app.exec(); | ||||
rv = app.getReturnValue(); | |||||
} else { | |||||
// A dialog with detailed error will have been shown by InitError() | |||||
rv = EXIT_FAILURE; | |||||
} | |||||
} catch (const std::exception &e) { | } catch (const std::exception &e) { | ||||
PrintExceptionContinue(&e, "Runaway exception"); | PrintExceptionContinue(&e, "Runaway exception"); | ||||
app.handleRunawayException(QString::fromStdString(GetWarnings("gui"))); | app.handleRunawayException(QString::fromStdString(GetWarnings("gui"))); | ||||
} catch (...) { | } catch (...) { | ||||
PrintExceptionContinue(nullptr, "Runaway exception"); | PrintExceptionContinue(nullptr, "Runaway exception"); | ||||
app.handleRunawayException(QString::fromStdString(GetWarnings("gui"))); | app.handleRunawayException(QString::fromStdString(GetWarnings("gui"))); | ||||
} | } | ||||
return app.getReturnValue(); | return rv; | ||||
} | } | ||||
#endif // BITCOIN_QT_TEST | #endif // BITCOIN_QT_TEST |
Remove. We don't support older version of Qt.