mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-03 09:56:38 -05:00
Merge pull request #4534
33357b2
qt: Start core thread only when needed (Wladimir J. van der Laan)c715ff5
ui: Replace some LogPrintfs with qDebug() (Wladimir J. van der Laan)96ff9d6
Can't log to debug log before chain params initialized (Wladimir J. van der Laan)
This commit is contained in:
commit
66f3d0679f
4 changed files with 30 additions and 13 deletions
|
@ -91,3 +91,7 @@ bool SelectBaseParamsFromCommandLine() {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AreBaseParamsConfigured() {
|
||||||
|
return pCurrentBaseParams != NULL;
|
||||||
|
}
|
||||||
|
|
|
@ -49,4 +49,10 @@ void SelectBaseParams(CBaseChainParams::Network network);
|
||||||
*/
|
*/
|
||||||
bool SelectBaseParamsFromCommandLine();
|
bool SelectBaseParamsFromCommandLine();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if SelectBaseParamsFromCommandLine() has been called to select
|
||||||
|
* a network.
|
||||||
|
*/
|
||||||
|
bool AreBaseParamsConfigured();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
|
|
||||||
#include <boost/filesystem/operations.hpp>
|
#include <boost/filesystem/operations.hpp>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QDebug>
|
||||||
#include <QLibraryInfo>
|
#include <QLibraryInfo>
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
@ -237,7 +238,7 @@ void BitcoinCore::initialize()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LogPrintf("Running AppInit2 in thread\n");
|
qDebug() << __func__ << ": Running AppInit2 in thread";
|
||||||
int rv = AppInit2(threadGroup);
|
int rv = AppInit2(threadGroup);
|
||||||
if(rv)
|
if(rv)
|
||||||
{
|
{
|
||||||
|
@ -258,11 +259,11 @@ void BitcoinCore::shutdown()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LogPrintf("Running Shutdown in thread\n");
|
qDebug() << __func__ << ": Running Shutdown in thread";
|
||||||
threadGroup.interrupt_all();
|
threadGroup.interrupt_all();
|
||||||
threadGroup.join_all();
|
threadGroup.join_all();
|
||||||
Shutdown();
|
Shutdown();
|
||||||
LogPrintf("Shutdown finished\n");
|
qDebug() << __func__ << ": Shutdown finished";
|
||||||
emit shutdownResult(1);
|
emit shutdownResult(1);
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
handleRunawayException(&e);
|
handleRunawayException(&e);
|
||||||
|
@ -285,15 +286,17 @@ BitcoinApplication::BitcoinApplication(int &argc, char **argv):
|
||||||
returnValue(0)
|
returnValue(0)
|
||||||
{
|
{
|
||||||
setQuitOnLastWindowClosed(false);
|
setQuitOnLastWindowClosed(false);
|
||||||
startThread();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BitcoinApplication::~BitcoinApplication()
|
BitcoinApplication::~BitcoinApplication()
|
||||||
{
|
{
|
||||||
LogPrintf("Stopping thread\n");
|
if(coreThread)
|
||||||
emit stopThread();
|
{
|
||||||
coreThread->wait();
|
qDebug() << __func__ << ": Stopping thread";
|
||||||
LogPrintf("Stopped thread\n");
|
emit stopThread();
|
||||||
|
coreThread->wait();
|
||||||
|
qDebug() << __func__ << ": Stopped thread";
|
||||||
|
}
|
||||||
|
|
||||||
delete window;
|
delete window;
|
||||||
window = 0;
|
window = 0;
|
||||||
|
@ -336,6 +339,8 @@ void BitcoinApplication::createSplashScreen(bool isaTestNet)
|
||||||
|
|
||||||
void BitcoinApplication::startThread()
|
void BitcoinApplication::startThread()
|
||||||
{
|
{
|
||||||
|
if(coreThread)
|
||||||
|
return;
|
||||||
coreThread = new QThread(this);
|
coreThread = new QThread(this);
|
||||||
BitcoinCore *executor = new BitcoinCore();
|
BitcoinCore *executor = new BitcoinCore();
|
||||||
executor->moveToThread(coreThread);
|
executor->moveToThread(coreThread);
|
||||||
|
@ -355,13 +360,15 @@ void BitcoinApplication::startThread()
|
||||||
|
|
||||||
void BitcoinApplication::requestInitialize()
|
void BitcoinApplication::requestInitialize()
|
||||||
{
|
{
|
||||||
LogPrintf("Requesting initialize\n");
|
qDebug() << __func__ << ": Requesting initialize";
|
||||||
|
startThread();
|
||||||
emit requestedInitialize();
|
emit requestedInitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitcoinApplication::requestShutdown()
|
void BitcoinApplication::requestShutdown()
|
||||||
{
|
{
|
||||||
LogPrintf("Requesting shutdown\n");
|
qDebug() << __func__ << ": Requesting shutdown";
|
||||||
|
startThread();
|
||||||
window->hide();
|
window->hide();
|
||||||
window->setClientModel(0);
|
window->setClientModel(0);
|
||||||
pollShutdownTimer->stop();
|
pollShutdownTimer->stop();
|
||||||
|
@ -383,7 +390,7 @@ void BitcoinApplication::requestShutdown()
|
||||||
|
|
||||||
void BitcoinApplication::initializeResult(int retval)
|
void BitcoinApplication::initializeResult(int retval)
|
||||||
{
|
{
|
||||||
LogPrintf("Initialization result: %i\n", retval);
|
qDebug() << __func__ << ": Initialization result: " << retval;
|
||||||
// Set exit result: 0 if successful, 1 if failure
|
// Set exit result: 0 if successful, 1 if failure
|
||||||
returnValue = retval ? 0 : 1;
|
returnValue = retval ? 0 : 1;
|
||||||
if(retval)
|
if(retval)
|
||||||
|
@ -438,7 +445,7 @@ void BitcoinApplication::initializeResult(int retval)
|
||||||
|
|
||||||
void BitcoinApplication::shutdownResult(int retval)
|
void BitcoinApplication::shutdownResult(int retval)
|
||||||
{
|
{
|
||||||
LogPrintf("Shutdown result: %i\n", retval);
|
qDebug() << __func__ << ": Shutdown result: " << retval;
|
||||||
quit(); // Exit main loop after shutdown finished
|
quit(); // Exit main loop after shutdown finished
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -205,7 +205,7 @@ int LogPrintStr(const std::string &str)
|
||||||
// print to console
|
// print to console
|
||||||
ret = fwrite(str.data(), 1, str.size(), stdout);
|
ret = fwrite(str.data(), 1, str.size(), stdout);
|
||||||
}
|
}
|
||||||
else if (fPrintToDebugLog)
|
else if (fPrintToDebugLog && AreBaseParamsConfigured())
|
||||||
{
|
{
|
||||||
static bool fStartedNewLine = true;
|
static bool fStartedNewLine = true;
|
||||||
boost::call_once(&DebugPrintInit, debugPrintInitFlag);
|
boost::call_once(&DebugPrintInit, debugPrintInitFlag);
|
||||||
|
|
Loading…
Add table
Reference in a new issue