@@ -487,9 +487,7 @@ RPCConsole::RPCConsole(interfaces::Node& node, const PlatformStyle *_platformSty
487487 m_node.rpcSetTimerInterfaceIfUnset (rpcTimerInterface);
488488
489489 setTrafficGraphRange (INITIAL_TRAFFIC_GRAPH_MINS);
490-
491- ui->detailWidget ->hide ();
492- ui->peerHeading ->setText (tr (" Select a peer to view detailed information." ));
490+ updateDetailWidget ();
493491
494492 consoleFontSize = settings.value (fontSizeSettingsKey, QFont ().pointSize ()).toInt ();
495493 clear ();
@@ -620,7 +618,7 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_
620618 connect (disconnectAction, &QAction::triggered, this , &RPCConsole::disconnectSelectedNode);
621619
622620 // peer table signal handling - update peer details when selecting new node
623- connect (ui->peerWidget ->selectionModel (), &QItemSelectionModel::selectionChanged, this , &RPCConsole::peerSelected );
621+ connect (ui->peerWidget ->selectionModel (), &QItemSelectionModel::selectionChanged, this , &RPCConsole::updateDetailWidget );
624622 // peer table signal handling - update peer details when new nodes are added to the model
625623 connect (model->getPeerTableModel (), &PeerTableModel::layoutChanged, this , &RPCConsole::peerLayoutChanged);
626624 // peer table signal handling - cache selected node ids
@@ -1015,18 +1013,6 @@ void RPCConsole::updateTrafficStats(quint64 totalBytesIn, quint64 totalBytesOut)
10151013 ui->lblBytesOut ->setText (GUIUtil::formatBytes (totalBytesOut));
10161014}
10171015
1018- void RPCConsole::peerSelected (const QItemSelection &selected, const QItemSelection &deselected)
1019- {
1020- Q_UNUSED (deselected);
1021-
1022- if (!clientModel || !clientModel->getPeerTableModel () || selected.indexes ().isEmpty ())
1023- return ;
1024-
1025- const CNodeCombinedStats *stats = clientModel->getPeerTableModel ()->getNodeStats (selected.indexes ().first ().row ());
1026- if (stats)
1027- updateNodeDetail (stats);
1028- }
1029-
10301016void RPCConsole::peerLayoutAboutToChange ()
10311017{
10321018 QModelIndexList selected = ui->peerWidget ->selectionModel ()->selectedIndexes ();
@@ -1043,7 +1029,6 @@ void RPCConsole::peerLayoutChanged()
10431029 if (!clientModel || !clientModel->getPeerTableModel ())
10441030 return ;
10451031
1046- const CNodeCombinedStats *stats = nullptr ;
10471032 bool fUnselect = false ;
10481033 bool fReselect = false ;
10491034
@@ -1074,9 +1059,6 @@ void RPCConsole::peerLayoutChanged()
10741059 fUnselect = true ;
10751060 fReselect = true ;
10761061 }
1077-
1078- // get fresh stats on the detail node.
1079- stats = clientModel->getPeerTableModel ()->getNodeStats (detailNodeRow);
10801062 }
10811063
10821064 if (fUnselect && selectedRow >= 0 ) {
@@ -1091,12 +1073,20 @@ void RPCConsole::peerLayoutChanged()
10911073 }
10921074 }
10931075
1094- if (stats)
1095- updateNodeDetail (stats);
1076+ updateDetailWidget ();
10961077}
10971078
1098- void RPCConsole::updateNodeDetail ( const CNodeCombinedStats *stats )
1079+ void RPCConsole::updateDetailWidget ( )
10991080{
1081+ QModelIndexList selected_rows;
1082+ auto selection_model = ui->peerWidget ->selectionModel ();
1083+ if (selection_model) selected_rows = selection_model->selectedRows ();
1084+ if (!clientModel || !clientModel->getPeerTableModel () || selected_rows.size () != 1 ) {
1085+ ui->detailWidget ->hide ();
1086+ ui->peerHeading ->setText (tr (" Select a peer to view detailed information." ));
1087+ return ;
1088+ }
1089+ const CNodeCombinedStats *stats = clientModel->getPeerTableModel ()->getNodeStats (selected_rows.first ().row ());
11001090 // update the detail ui with latest node information
11011091 QString peerAddrDetails (QString::fromStdString (stats->nodeStats .addrName ) + " " );
11021092 peerAddrDetails += tr (" (node id: %1)" ).arg (QString::number (stats->nodeStats .nodeid ));
@@ -1254,8 +1244,7 @@ void RPCConsole::clearSelectedNode()
12541244{
12551245 ui->peerWidget ->selectionModel ()->clearSelection ();
12561246 cachedNodeids.clear ();
1257- ui->detailWidget ->hide ();
1258- ui->peerHeading ->setText (tr (" Select a peer to view detailed information." ));
1247+ updateDetailWidget ();
12591248}
12601249
12611250void RPCConsole::showOrHideBanTableIfRequired ()
0 commit comments