Disconnect BlockNotifyGenesisWait and RPCNotifyBlockChange properly. Remove no-op CClientUIInterface::[signal_name]_disconnect.
This commit is contained in:
parent
0baf4b1f96
commit
6dd469a3be
3 changed files with 7 additions and 10 deletions
10
src/init.cpp
10
src/init.cpp
|
@ -339,14 +339,15 @@ static void registerSignalHandler(int signal, void(*handler)(int))
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static boost::signals2::connection rpc_notify_block_change_connection;
|
||||||
static void OnRPCStarted()
|
static void OnRPCStarted()
|
||||||
{
|
{
|
||||||
uiInterface.NotifyBlockTip_connect(&RPCNotifyBlockChange);
|
rpc_notify_block_change_connection = uiInterface.NotifyBlockTip_connect(&RPCNotifyBlockChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void OnRPCStopped()
|
static void OnRPCStopped()
|
||||||
{
|
{
|
||||||
uiInterface.NotifyBlockTip_disconnect(&RPCNotifyBlockChange);
|
rpc_notify_block_change_connection.disconnect();
|
||||||
RPCNotifyBlockChange(false, nullptr);
|
RPCNotifyBlockChange(false, nullptr);
|
||||||
g_best_block_cv.notify_all();
|
g_best_block_cv.notify_all();
|
||||||
LogPrint(BCLog::RPC, "RPC stopped.\n");
|
LogPrint(BCLog::RPC, "RPC stopped.\n");
|
||||||
|
@ -1687,8 +1688,9 @@ bool AppInitMain(InitInterfaces& interfaces)
|
||||||
|
|
||||||
// Either install a handler to notify us when genesis activates, or set fHaveGenesis directly.
|
// Either install a handler to notify us when genesis activates, or set fHaveGenesis directly.
|
||||||
// No locking, as this happens before any background thread is started.
|
// No locking, as this happens before any background thread is started.
|
||||||
|
boost::signals2::connection block_notify_genesis_wait_connection;
|
||||||
if (chainActive.Tip() == nullptr) {
|
if (chainActive.Tip() == nullptr) {
|
||||||
uiInterface.NotifyBlockTip_connect(BlockNotifyGenesisWait);
|
block_notify_genesis_wait_connection = uiInterface.NotifyBlockTip_connect(BlockNotifyGenesisWait);
|
||||||
} else {
|
} else {
|
||||||
fHaveGenesis = true;
|
fHaveGenesis = true;
|
||||||
}
|
}
|
||||||
|
@ -1712,7 +1714,7 @@ bool AppInitMain(InitInterfaces& interfaces)
|
||||||
while (!fHaveGenesis && !ShutdownRequested()) {
|
while (!fHaveGenesis && !ShutdownRequested()) {
|
||||||
g_genesis_wait_cv.wait_for(lock, std::chrono::milliseconds(500));
|
g_genesis_wait_cv.wait_for(lock, std::chrono::milliseconds(500));
|
||||||
}
|
}
|
||||||
uiInterface.NotifyBlockTip_disconnect(BlockNotifyGenesisWait);
|
block_notify_genesis_wait_connection.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ShutdownRequested()) {
|
if (ShutdownRequested()) {
|
||||||
|
|
|
@ -28,10 +28,6 @@ struct UISignals {
|
||||||
boost::signals2::connection CClientUIInterface::signal_name##_connect(std::function<signal_name##Sig> fn) \
|
boost::signals2::connection CClientUIInterface::signal_name##_connect(std::function<signal_name##Sig> fn) \
|
||||||
{ \
|
{ \
|
||||||
return g_ui_signals.signal_name.connect(fn); \
|
return g_ui_signals.signal_name.connect(fn); \
|
||||||
} \
|
|
||||||
void CClientUIInterface::signal_name##_disconnect(std::function<signal_name##Sig> fn) \
|
|
||||||
{ \
|
|
||||||
return g_ui_signals.signal_name.disconnect(&fn); \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ADD_SIGNALS_IMPL_WRAPPER(ThreadSafeMessageBox);
|
ADD_SIGNALS_IMPL_WRAPPER(ThreadSafeMessageBox);
|
||||||
|
|
|
@ -81,8 +81,7 @@ public:
|
||||||
#define ADD_SIGNALS_DECL_WRAPPER(signal_name, rtype, ...) \
|
#define ADD_SIGNALS_DECL_WRAPPER(signal_name, rtype, ...) \
|
||||||
rtype signal_name(__VA_ARGS__); \
|
rtype signal_name(__VA_ARGS__); \
|
||||||
using signal_name##Sig = rtype(__VA_ARGS__); \
|
using signal_name##Sig = rtype(__VA_ARGS__); \
|
||||||
boost::signals2::connection signal_name##_connect(std::function<signal_name##Sig> fn); \
|
boost::signals2::connection signal_name##_connect(std::function<signal_name##Sig> fn);
|
||||||
void signal_name##_disconnect(std::function<signal_name##Sig> fn);
|
|
||||||
|
|
||||||
/** Show message box. */
|
/** Show message box. */
|
||||||
ADD_SIGNALS_DECL_WRAPPER(ThreadSafeMessageBox, bool, const std::string& message, const std::string& caption, unsigned int style);
|
ADD_SIGNALS_DECL_WRAPPER(ThreadSafeMessageBox, bool, const std::string& message, const std::string& caption, unsigned int style);
|
||||||
|
|
Loading…
Reference in a new issue