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.
Concept ACK.
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.
if (!clientModel) return;
auto selected_rows = ui->peerWidget->selectionModel()->selectedRows();
Tested cb262e7680b274ff8f0c500965cfe4873108cbd1 on Linux Mint 20 (x86_64, Qt 5.12.8):
$ lldb ./src/qt/bitcoin-qt -- -testnet
(lldb) target create "./src/qt/bitcoin-qt"
Current executable set to '/home/hebasto/GitHub/gui/src/qt/bitcoin-qt' (x86_64).
(lldb) settings set -- target.run-args "-testnet"
(lldb) run
Process 20230 launched: '/home/hebasto/GitHub/gui/src/qt/bitcoin-qt' (x86_64)
Process 20230 stopped
* thread [#1](/bitcoin-core-gui/1/), name = 'bitcoin-qt', stop reason = signal SIGSEGV: invalid address (fault address: 0x8)
frame [#0](/bitcoin-core-gui/0/): 0x00007ffff6d50711 libQt5Core.so.5`QItemSelectionModel::selection() const + 17
libQt5Core.so.5`QItemSelectionModel::selection:
-> 0x7ffff6d50711 <+17>: movq 0x8(%rsi), %rbx
0x7ffff6d50715 <+21>: movq %fs:0x28, %rax
0x7ffff6d5071e <+30>: movq %rax, 0x28(%rsp)
0x7ffff6d50723 <+35>: xorl %eax, %eax
(lldb) bt
* thread [#1](/bitcoin-core-gui/1/), name = 'bitcoin-qt', stop reason = signal SIGSEGV: invalid address (fault address: 0x8)
* frame [#0](/bitcoin-core-gui/0/): 0x00007ffff6d50711 libQt5Core.so.5`QItemSelectionModel::selection() const + 17
frame [#1](/bitcoin-core-gui/1/): 0x00007ffff6d5088e libQt5Core.so.5`QItemSelectionModel::selectedRows(int) const + 94
frame [#2](/bitcoin-core-gui/2/): 0x000055555562468f bitcoin-qt`RPCConsole::updateDetailWidget(this=0x0000555556514ff0) at rpcconsole.cpp:1083:60
frame [#3](/bitcoin-core-gui/3/): 0x0000555555622cc7 bitcoin-qt`RPCConsole::RPCConsole(this=0x0000555556514ff0, node=<unavailable>, _platformStyle=<unavailable>, parent=<unavailable>) at rpcconsole.cpp:495:5
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
frame [#5](/bitcoin-core-gui/5/): 0x00005555555d37b2 bitcoin-qt`BitcoinApplication::createWindow(this=0x00007fffffffdbf8, networkStyle=<unavailable>) at bitcoin.cpp:252:18
frame [#6](/bitcoin-core-gui/6/): 0x00005555555d6247 bitcoin-qt`GuiMain(argc=<unavailable>, argv=<unavailable>) at bitcoin.cpp:583:13
frame [#7](/bitcoin-core-gui/7/): 0x00005555555d22e3 bitcoin-qt`main(argc=<unavailable>, argv=<unavailable>) at main.cpp:21:43
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
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?
Strange, in macos that didn't happen. Was that on startup? On opening peers tab?
On startup.
Right, I saw qabstractitemview.cpp where it also has the check.
@promag How about the following patch which fixes the problem described in the OP:
--- a/src/qt/rpcconsole.cpp
+++ b/src/qt/rpcconsole.cpp
@@ -593,7 +593,7 @@ void RPCConsole::setClientModel(ClientModel *model)
ui->peerWidget->verticalHeader()->hide();
ui->peerWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
ui->peerWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
- ui->peerWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
+ ui->peerWidget->setSelectionMode(QAbstractItemView::SingleSelection);
ui->peerWidget->setContextMenuPolicy(Qt::CustomContextMenu);
ui->peerWidget->setColumnWidth(PeerTableModel::Address, ADDRESS_COLUMN_WIDTH);
ui->peerWidget->setColumnWidth(PeerTableModel::Subversion, SUBVERSION_COLUMN_WIDTH);
?
Multiple selection is enabled and used when you use the context menu.
1062 | @@ -1078,7 +1063,6 @@ void RPCConsole::peerLayoutChanged() 1063 | } 1064 | 1065 | // get fresh stats on the detail node. 1066 | - stats = clientModel->getPeerTableModel()->getNodeStats(detailNodeRow);
nit: not sure about the two lines above?
Removed those.
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:
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:
const auto selection_model = ui->peerWidget->selectionModel();
ACK 76277cc77dea39b53e09ee1c440cd37270826201, tested on Linux Mint 20 (Qt 5.12.8).
tested https://github.com/bitcoin-core/gui/commit/76277cc77dea39b53e09ee1c440cd37270826201 on debian and lubuntu VM's on top of master and other changes so far LGTM
@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.
@hebasto right, I've added it just to be sure view is updated. I also thought of blocking signals to prevent unnecessary updates because of that signal. Another thing we could do is to add 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.
Either hide or show last selected looks good to me.
Tested ACK 76277cc77dea39b53e09ee1c440cd37270826201. Should this be considered a bugfix?
Thanks.