Skip to content

Commit 639563d

Browse files
committed
qt: Revamp ClientModel code to handle NumConnectionsChanged core signal
No behavior change.
1 parent 508e2dc commit 639563d

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

src/qt/clientmodel.cpp

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,6 @@ uint256 ClientModel::getBestBlockHash()
148148
return m_cached_tip_blocks;
149149
}
150150

151-
void ClientModel::updateNumConnections(int numConnections)
152-
{
153-
Q_EMIT numConnectionsChanged(numConnections);
154-
}
155-
156151
void ClientModel::updateNetworkActive(bool networkActive)
157152
{
158153
Q_EMIT networkActiveChanged(networkActive);
@@ -236,14 +231,6 @@ void ClientModel::updateBanlist()
236231
}
237232

238233
// Handlers for core signals
239-
static void NotifyNumConnectionsChanged(ClientModel *clientmodel, int newNumConnections)
240-
{
241-
// Too noisy: qDebug() << "NotifyNumConnectionsChanged: " + QString::number(newNumConnections);
242-
bool invoked = QMetaObject::invokeMethod(clientmodel, "updateNumConnections", Qt::QueuedConnection,
243-
Q_ARG(int, newNumConnections));
244-
assert(invoked);
245-
}
246-
247234
static void NotifyNetworkActiveChanged(ClientModel *clientmodel, bool networkActive)
248235
{
249236
bool invoked = QMetaObject::invokeMethod(clientmodel, "updateNetworkActive", Qt::QueuedConnection,
@@ -301,7 +288,10 @@ void ClientModel::subscribeToCoreSignals()
301288
[this](const std::string& title, int progress, [[maybe_unused]] bool resume_possible) {
302289
Q_EMIT showProgress(QString::fromStdString(title), progress);
303290
});
304-
m_handler_notify_num_connections_changed = m_node.handleNotifyNumConnectionsChanged(std::bind(NotifyNumConnectionsChanged, this, std::placeholders::_1));
291+
m_handler_notify_num_connections_changed = m_node.handleNotifyNumConnectionsChanged(
292+
[this](int new_num_connections) {
293+
Q_EMIT numConnectionsChanged(new_num_connections);
294+
});
305295
m_handler_notify_network_active_changed = m_node.handleNotifyNetworkActiveChanged(std::bind(NotifyNetworkActiveChanged, this, std::placeholders::_1));
306296
m_handler_notify_alert_changed = m_node.handleNotifyAlertChanged(std::bind(NotifyAlertChanged, this));
307297
m_handler_banned_list_changed = m_node.handleBannedListChanged(std::bind(BannedListChanged, this));

src/qt/clientmodel.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ class ClientModel : public QObject
122122
void showProgress(const QString &title, int nProgress);
123123

124124
public Q_SLOTS:
125-
void updateNumConnections(int numConnections);
126125
void updateNetworkActive(bool networkActive);
127126
void updateAlert();
128127
void updateBanlist();

0 commit comments

Comments
 (0)