From 76fd7b8c2677dc145a67e86153d629b43d2a92e5 Mon Sep 17 00:00:00 2001 From: Cozz Lovan Date: Sun, 13 Jul 2014 06:27:29 +0200 Subject: [PATCH] [Qt] Fix segfault when launched with -disablewallet --- src/qt/bitcoingui.cpp | 11 +++++++---- src/qt/rpcconsole.cpp | 39 +++++++++++++++++++++++++++++---------- src/qt/rpcconsole.h | 2 ++ 3 files changed, 38 insertions(+), 14 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 6b3aa2a2..3ef04d96 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -159,10 +159,13 @@ BitcoinGUI::BitcoinGUI(bool fIsTestnet, QWidget *parent) : labelEncryptionIcon = new QLabel(); labelConnectionsIcon = new QLabel(); labelBlocksIcon = new QLabel(); - frameBlocksLayout->addStretch(); - frameBlocksLayout->addWidget(unitDisplayControl); - frameBlocksLayout->addStretch(); - frameBlocksLayout->addWidget(labelEncryptionIcon); + if(enableWallet) + { + frameBlocksLayout->addStretch(); + frameBlocksLayout->addWidget(unitDisplayControl); + frameBlocksLayout->addStretch(); + frameBlocksLayout->addWidget(labelEncryptionIcon); + } frameBlocksLayout->addStretch(); frameBlocksLayout->addWidget(labelConnectionsIcon); frameBlocksLayout->addStretch(); diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index e1f40ddd..9b67f812 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -473,6 +473,10 @@ void RPCConsole::on_tabWidget_currentChanged(int index) { ui->lineEdit->setFocus(); } + else if(ui->tabWidget->widget(index) == ui->tab_peers) + { + initPeerTable(); + } } void RPCConsole::on_openDebugLogfileButton_clicked() @@ -648,17 +652,10 @@ void RPCConsole::updateNodeDetail(const CNodeCombinedStats *combinedStats) ui->peerBanScore->setText(tr("Fetching...")); } -// We override the virtual resizeEvent of the QWidget to adjust tables column -// sizes as the tables width is proportional to the dialogs width. -void RPCConsole::resizeEvent(QResizeEvent *event) +void RPCConsole::initPeerTable() { - QWidget::resizeEvent(event); - columnResizingFixer->stretchColumnWidth(PeerTableModel::Address); -} - -void RPCConsole::showEvent(QShowEvent *event) -{ - QWidget::showEvent(event); + if (!clientModel) + return; // peerWidget needs a resize in case the dialog has non-default geometry columnResizingFixer->stretchColumnWidth(PeerTableModel::Address); @@ -667,10 +664,32 @@ void RPCConsole::showEvent(QShowEvent *event) clientModel->getPeerTableModel()->startAutoRefresh(1000); } +// We override the virtual resizeEvent of the QWidget to adjust tables column +// sizes as the tables width is proportional to the dialogs width. +void RPCConsole::resizeEvent(QResizeEvent *event) +{ + QWidget::resizeEvent(event); + + if (!clientModel) + return; + + columnResizingFixer->stretchColumnWidth(PeerTableModel::Address); +} + +void RPCConsole::showEvent(QShowEvent *event) +{ + QWidget::showEvent(event); + + initPeerTable(); +} + void RPCConsole::hideEvent(QHideEvent *event) { QWidget::hideEvent(event); + if (!clientModel) + return; + // stop PeerTableModel auto refresh clientModel->getPeerTableModel()->stopAutoRefresh(); } diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h index 3aeff3ea..94672b30 100644 --- a/src/qt/rpcconsole.h +++ b/src/qt/rpcconsole.h @@ -47,6 +47,8 @@ protected: private: /** show detailed information on ui about selected node */ void updateNodeDetail(const CNodeCombinedStats *combinedStats); + /** initialize peer table */ + void initPeerTable(); enum ColumnWidths {