Currently if multiple peers are selected the peer detail view shows the first new selected peer.
With this PR the peer detail view is hidden when multiple peers are selected. It is also a slight refactor to simplify and remove duplicate code.
Currently if multiple peers are selected the peer detail view shows the first new selected peer.
With this PR the peer detail view is hidden when multiple peers are selected. It is also a slight refactor to simplify and remove duplicate code.
1084-void RPCConsole::updateNodeDetail(const CNodeCombinedStats *stats)
1085+void RPCConsole::updateDetailWidget()
1086 {
1087+ auto selected_rows = ui->peerWidget->selectionModel()->selectedRows();
1088+ if (!clientModel || !clientModel->getPeerTableModel() || selected_rows.size() != 1) {
1089+ ui->detailWidget->hide();
Nit check for access to clientModel ? Had some sporadic segfaults, with check patch so far none hmm.
0if (!clientModel) return;
1 auto selected_rows = ui->peerWidget->selectionModel()->selectedRows();
Tested cb262e7680b274ff8f0c500965cfe4873108cbd1 on Linux Mint 20 (x86_64, Qt 5.12.8):
0$ lldb ./src/qt/bitcoin-qt -- -testnet
1(lldb) target create "./src/qt/bitcoin-qt"
2Current executable set to '/home/hebasto/GitHub/gui/src/qt/bitcoin-qt' (x86_64).
3(lldb) settings set -- target.run-args "-testnet"
4(lldb) run
5Process 20230 launched: '/home/hebasto/GitHub/gui/src/qt/bitcoin-qt' (x86_64)
6Process 20230 stopped
7* thread [#1](/bitcoin-core-gui/1/), name = 'bitcoin-qt', stop reason = signal SIGSEGV: invalid address (fault address: 0x8)
8 frame [#0](/bitcoin-core-gui/0/): 0x00007ffff6d50711 libQt5Core.so.5`QItemSelectionModel::selection() const + 17
9libQt5Core.so.5`QItemSelectionModel::selection:
10-> 0x7ffff6d50711 <+17>: movq 0x8(%rsi), %rbx
11 0x7ffff6d50715 <+21>: movq %fs:0x28, %rax
12 0x7ffff6d5071e <+30>: movq %rax, 0x28(%rsp)
13 0x7ffff6d50723 <+35>: xorl %eax, %eax
14(lldb) bt
15* thread [#1](/bitcoin-core-gui/1/), name = 'bitcoin-qt', stop reason = signal SIGSEGV: invalid address (fault address: 0x8)
16 * frame [#0](/bitcoin-core-gui/0/): 0x00007ffff6d50711 libQt5Core.so.5`QItemSelectionModel::selection() const + 17
17 frame [#1](/bitcoin-core-gui/1/): 0x00007ffff6d5088e libQt5Core.so.5`QItemSelectionModel::selectedRows(int) const + 94
18 frame [#2](/bitcoin-core-gui/2/): 0x000055555562468f bitcoin-qt`RPCConsole::updateDetailWidget(this=0x0000555556514ff0) at rpcconsole.cpp:1083:60
19 frame [#3](/bitcoin-core-gui/3/): 0x0000555555622cc7 bitcoin-qt`RPCConsole::RPCConsole(this=0x0000555556514ff0, node=<unavailable>, _platformStyle=<unavailable>, parent=<unavailable>) at rpcconsole.cpp:495:5
20 frame [#4](/bitcoin-core-gui/4/): 0x00005555555dc3d3 bitcoin-qt`BitcoinGUI::BitcoinGUI(this=0x0000555556598400, node=0x0000555556369b40, _platformStyle=0x00005555564fa900, networkStyle=<unavailable>, parent=<unavailable>) at bitcoingui.cpp:97:22
21 frame [#5](/bitcoin-core-gui/5/): 0x00005555555d37b2 bitcoin-qt`BitcoinApplication::createWindow(this=0x00007fffffffdbf8, networkStyle=<unavailable>) at bitcoin.cpp:252:18
22 frame [#6](/bitcoin-core-gui/6/): 0x00005555555d6247 bitcoin-qt`GuiMain(argc=<unavailable>, argv=<unavailable>) at bitcoin.cpp:583:13
23 frame [#7](/bitcoin-core-gui/7/): 0x00005555555d22e3 bitcoin-qt`main(argc=<unavailable>, argv=<unavailable>) at main.cpp:21:43
24 frame [#8](/bitcoin-core-gui/8/): 0x00007ffff63020b3 libc.so.6`__libc_start_main(main=(bitcoin-qt`main at main.cpp:21), argc=2, argv=0x00007fffffffdd98, init=<unavailable>, fini=<unavailable>, rtld_fini=<unavailable>, stack_end=0x00007fffffffdd88) at libc-start.c:308:16
25 frame [#9](/bitcoin-core-gui/9/): 0x00005555555d220e bitcoin-qt`_start + 46
Strange, in macos that didn’t happen. Was that on startup? On opening peers tab?
On startup.
@promag How about the following patch which fixes the problem described in the OP:
0--- a/src/qt/rpcconsole.cpp
1+++ b/src/qt/rpcconsole.cpp
2@@ -593,7 +593,7 @@ void RPCConsole::setClientModel(ClientModel *model)
3 ui->peerWidget->verticalHeader()->hide();
4 ui->peerWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
5 ui->peerWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
6- ui->peerWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
7+ ui->peerWidget->setSelectionMode(QAbstractItemView::SingleSelection);
8 ui->peerWidget->setContextMenuPolicy(Qt::CustomContextMenu);
9 ui->peerWidget->setColumnWidth(PeerTableModel::Address, ADDRESS_COLUMN_WIDTH);
10 ui->peerWidget->setColumnWidth(PeerTableModel::Subversion, SUBVERSION_COLUMN_WIDTH);
?
1062@@ -1078,7 +1063,6 @@ void RPCConsole::peerLayoutChanged()
1063 }
1064
1065 // get fresh stats on the detail node.
1066- stats = clientModel->getPeerTableModel()->getNodeStats(detailNodeRow);
1089+ if (!clientModel || !clientModel->getPeerTableModel() || selected_rows.size() != 1) {
1090+ ui->detailWidget->hide();
1091+ ui->peerHeading->setText(tr("Select a peer to view detailed information."));
1092+ return;
1093+ }
1094+ const CNodeCombinedStats *stats = clientModel->getPeerTableModel()->getNodeStats(selected_rows.first().row());
nanonit:
0
1 const CNodeCombinedStats* stats = clientModel->getPeerTableModel()->getNodeStats(selected_rows.first().row());
or even use const auto
(that seems preferable to me).
1082
1083-void RPCConsole::updateNodeDetail(const CNodeCombinedStats *stats)
1084+void RPCConsole::updateDetailWidget()
1085 {
1086+ QModelIndexList selected_rows;
1087+ auto selection_model = ui->peerWidget->selectionModel();
nit:
0 const auto selection_model = ui->peerWidget->selectionModel();
@promag Due to this connection https://github.com/bitcoin-core/gui/blob/76277cc77dea39b53e09ee1c440cd37270826201/src/qt/rpcconsole.cpp#L626
not sure if added in the latest push updateDetailWidget();
is required at all.
const CNodeCombinedStats* m_current_node_stats
, this way we can skip unnecessary work in updateDetailWidget
.
Weak Concept NACK
My mail program also shows the most-recently-touched message when selecting multiple, so the current behaviour isn’t too weird. I’m not sure there’s a benefit from hiding it?
Weak Concept NACK
My mail program also shows the most-recently-touched message when selecting multiple, so the current behaviour isn’t too weird. I’m not sure there’s a benefit from hiding it?
But the GUI shows not the most-recently-touched peer details rather the first-touched one’s. Therefore, this pull is an improvement, I think.