From 3ab747d8ffcb4886b1d21295c8cff8d0beb18703 Mon Sep 17 00:00:00 2001 From: crowning- Date: Mon, 25 May 2015 22:59:38 +0200 Subject: [PATCH] Wallet Repair Buttons added --- src/init.cpp | 3 +-- src/net.cpp | 12 +++++++----- src/net.h | 6 +++++- src/qt/dash.cpp | 19 ++++++++----------- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 6a8ef4d2b..5a2e55d40 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -146,8 +146,7 @@ static CCoinsViewErrorCatcher *pcoinscatcher = NULL; /** Preparing steps before restarting the wallet */ void Prepare_Restart() { - printf("Prepare_Restart called! ---------------------------\n"); - LogPrintf("%s: In progress...\n", __func__); + LogPrintf("%s: In progress...\n", __func__); static CCriticalSection cs_Shutdown; TRY_LOCK(cs_Shutdown, lockShutdown); if (!lockShutdown) diff --git a/src/net.cpp b/src/net.cpp index 119e235d3..e42557af7 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1739,11 +1739,13 @@ public: } instance_of_cnetcleanup; - - - - - +void CExplicitNetCleanup::callCleanup() +{ + // Explicit call to destructor of CNetCleanup because it's not implicitly called + // when the wallet is restarted from within the wallet itself. + CNetCleanup *tmp = new CNetCleanup(); + delete tmp; // Stroustrup's gonna kill me for that +} void RelayTransaction(const CTransaction& tx) { diff --git a/src/net.h b/src/net.h index 44c59abfb..5ec47ee24 100644 --- a/src/net.h +++ b/src/net.h @@ -672,7 +672,11 @@ public: static uint64_t GetTotalBytesSent(); }; - +class CExplicitNetCleanup +{ +public: + static void callCleanup(); +}; class CTransaction; void RelayTransaction(const CTransaction& tx); diff --git a/src/qt/dash.cpp b/src/qt/dash.cpp index bd385ffaa..c91eeac44 100644 --- a/src/qt/dash.cpp +++ b/src/qt/dash.cpp @@ -13,6 +13,7 @@ #include "guiconstants.h" #include "guiutil.h" #include "intro.h" +#include "net.h" #include "networkstyle.h" #include "optionsmodel.h" #include "splashscreen.h" @@ -280,25 +281,22 @@ void BitcoinCore::initialize() } } -void BitcoinCore::restart(QStringList args) // ToDo -{ - printf("restart in dash.cpp -------------------------------------------\n"); - for (int i = 0; i < args.size(); ++i){ - printf("%s\n", args.at(i).toStdString().c_str()); - } - +void BitcoinCore::restart(QStringList args) +{ try { qDebug() << __func__ << ": Running Restart in thread"; threadGroup.interrupt_all(); threadGroup.join_all(); - // Shutdown(); Prepare_Restart(); qDebug() << __func__ << ": Shutdown finished"; emit shutdownResult(1); - boost::this_thread::sleep( boost::posix_time::seconds(1) ); + CExplicitNetCleanup::callCleanup(); + + boost::this_thread::sleep( boost::posix_time::seconds(1)); QProcess::startDetached(QApplication::applicationFilePath(), args); - QCoreApplication::quit(); + qDebug() << __func__ << ": Restart initiated..."; + QCoreApplication::quit(); } catch (std::exception& e) { handleRunawayException(&e); } catch (...) { @@ -308,7 +306,6 @@ void BitcoinCore::restart(QStringList args) // ToDo void BitcoinCore::shutdown() { - printf("shutdown in dash.cpp -------------------------------------------\n"); try { qDebug() << __func__ << ": Running Shutdown in thread";