Skip to content

Commit f1a0314

Browse files
theunifanquake
andcommitted
gui: change combiner for signals to optional_last_value
optional_last_value, which does not throw, has replaced optional_value as boost's default combiner. Besides being better supported, it also doesn't trigger gcc's -Wmaybe-unitialized warning, presumably because exceptions no longer bubble-up out of signals: ```bash boost/signals2/last_value.hpp:54:36: warning: '*((void*)& value +1)' may be used uninitialized in this function [-Wmaybe-uninitialized] if(value) return value.get(); ``` The change in default happened in Boost 1.39.0 (along with the introduction of the signals 2 library. More information is available here: https://www.boost.org/doc/libs/1_73_0/doc/html/signals2/rationale.html#id-1.3.36.9.4 and here: https://www.boost.org/doc/libs/1_73_0/doc/html/boost/signals2/optional_last_value.html Co-authored-by: fanquake <[email protected]>
1 parent bb58866 commit f1a0314

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/node/ui_interface.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
#include <util/translation.h>
88

9-
#include <boost/signals2/last_value.hpp>
9+
#include <boost/signals2/optional_last_value.hpp>
1010
#include <boost/signals2/signal.hpp>
1111

1212
CClientUIInterface uiInterface;
1313

1414
struct UISignals {
15-
boost::signals2::signal<CClientUIInterface::ThreadSafeMessageBoxSig, boost::signals2::last_value<bool>> ThreadSafeMessageBox;
16-
boost::signals2::signal<CClientUIInterface::ThreadSafeQuestionSig, boost::signals2::last_value<bool>> ThreadSafeQuestion;
15+
boost::signals2::signal<CClientUIInterface::ThreadSafeMessageBoxSig, boost::signals2::optional_last_value<bool>> ThreadSafeMessageBox;
16+
boost::signals2::signal<CClientUIInterface::ThreadSafeQuestionSig, boost::signals2::optional_last_value<bool>> ThreadSafeQuestion;
1717
boost::signals2::signal<CClientUIInterface::InitMessageSig> InitMessage;
1818
boost::signals2::signal<CClientUIInterface::NotifyNumConnectionsChangedSig> NotifyNumConnectionsChanged;
1919
boost::signals2::signal<CClientUIInterface::NotifyNetworkActiveChangedSig> NotifyNetworkActiveChanged;
@@ -42,8 +42,8 @@ ADD_SIGNALS_IMPL_WRAPPER(NotifyBlockTip);
4242
ADD_SIGNALS_IMPL_WRAPPER(NotifyHeaderTip);
4343
ADD_SIGNALS_IMPL_WRAPPER(BannedListChanged);
4444

45-
bool CClientUIInterface::ThreadSafeMessageBox(const bilingual_str& message, const std::string& caption, unsigned int style) { return g_ui_signals.ThreadSafeMessageBox(message, caption, style); }
46-
bool CClientUIInterface::ThreadSafeQuestion(const bilingual_str& message, const std::string& non_interactive_message, const std::string& caption, unsigned int style) { return g_ui_signals.ThreadSafeQuestion(message, non_interactive_message, caption, style); }
45+
bool CClientUIInterface::ThreadSafeMessageBox(const bilingual_str& message, const std::string& caption, unsigned int style) { return g_ui_signals.ThreadSafeMessageBox(message, caption, style).value_or(false);}
46+
bool CClientUIInterface::ThreadSafeQuestion(const bilingual_str& message, const std::string& non_interactive_message, const std::string& caption, unsigned int style) { return g_ui_signals.ThreadSafeQuestion(message, non_interactive_message, caption, style).value_or(false);}
4747
void CClientUIInterface::InitMessage(const std::string& message) { return g_ui_signals.InitMessage(message); }
4848
void CClientUIInterface::NotifyNumConnectionsChanged(int newNumConnections) { return g_ui_signals.NotifyNumConnectionsChanged(newNumConnections); }
4949
void CClientUIInterface::NotifyNetworkActiveChanged(bool networkActive) { return g_ui_signals.NotifyNetworkActiveChanged(networkActive); }

test/lint/lint-includes.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ EXPECTED_BOOST_INCLUDES=(
6464
boost/preprocessor/cat.hpp
6565
boost/preprocessor/stringize.hpp
6666
boost/signals2/connection.hpp
67-
boost/signals2/last_value.hpp
67+
boost/signals2/optional_last_value.hpp
6868
boost/signals2/signal.hpp
6969
boost/test/unit_test.hpp
7070
boost/thread/condition_variable.hpp

0 commit comments

Comments
 (0)