@ -178,6 +178,10 @@ class BitcoinCore: public QObject
Q_OBJECT
Q_OBJECT
public :
public :
explicit BitcoinCore ( ) ;
explicit BitcoinCore ( ) ;
/** Basic initialization, before starting initialization/shutdown thread.
* Return true on success .
*/
static bool baseInitialize ( ) ;
public Q_SLOTS :
public Q_SLOTS :
void initialize ( ) ;
void initialize ( ) ;
@ -270,26 +274,32 @@ void BitcoinCore::handleRunawayException(const std::exception *e)
Q_EMIT runawayException ( QString : : fromStdString ( GetWarnings ( " gui " ) ) ) ;
Q_EMIT runawayException ( QString : : fromStdString ( GetWarnings ( " gui " ) ) ) ;
}
}
void BitcoinCore : : i nitialize( )
bool BitcoinCore : : baseI nitialize( )
{
{
try
{
qDebug ( ) < < __func__ < < " : Running initialization in thread " ;
if ( ! AppInitBasicSetup ( ) )
if ( ! AppInitBasicSetup ( ) )
{
{
Q_EMIT initializeResult ( false ) ;
return false ;
return ;
}
}
if ( ! AppInitParameterInteraction ( ) )
if ( ! AppInitParameterInteraction ( ) )
{
{
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 BitcoinCore : : initialize ( )
{
try
{
qDebug ( ) < < __func__ < < " : Running initialization in thread " ;
bool 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 ) {
@ -689,9 +699,14 @@ int main(int argc, char *argv[])
if ( GetBoolArg ( " -splash " , DEFAULT_SPLASHSCREEN ) & & ! GetBoolArg ( " -min " , false ) )
if ( GetBoolArg ( " -splash " , DEFAULT_SPLASHSCREEN ) & & ! GetBoolArg ( " -min " , false ) )
app . createSplashScreen ( networkStyle . data ( ) ) ;
app . createSplashScreen ( networkStyle . data ( ) ) ;
int rv = EXIT_SUCCESS ;
try
try
{
{
app . createWindow ( networkStyle . data ( ) ) ;
app . createWindow ( 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 ( BitcoinCore : : baseInitialize ( ) ) {
app . requestInitialize ( ) ;
app . requestInitialize ( ) ;
# if defined(Q_OS_WIN) && QT_VERSION >= 0x050000
# if defined(Q_OS_WIN) && QT_VERSION >= 0x050000
WinShutdownMonitor : : registerShutdownBlockReason ( QObject : : tr ( " %1 didn't yet exit safely... " ) . arg ( QObject : : tr ( PACKAGE_NAME ) ) , ( HWND ) app . getMainWinId ( ) ) ;
WinShutdownMonitor : : registerShutdownBlockReason ( QObject : : tr ( " %1 didn't yet exit safely... " ) . arg ( QObject : : tr ( PACKAGE_NAME ) ) , ( HWND ) app . getMainWinId ( ) ) ;
@ -699,6 +714,11 @@ int main(int argc, char *argv[])
app . exec ( ) ;
app . exec ( ) ;
app . requestShutdown ( ) ;
app . requestShutdown ( ) ;
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 " ) ) ) ;
@ -706,6 +726,6 @@ int main(int argc, char *argv[])
PrintExceptionContinue ( NULL , " Runaway exception " ) ;
PrintExceptionContinue ( NULL , " 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