Avoid accessing ShutdownRequested directly from qt, use Node interface

This commit is contained in:
UdjinM6 2021-03-19 18:02:25 +03:00
parent e20dc9f374
commit 221adfb426
No known key found for this signature in database
GPG Key ID: 83592BD1400D58D9
10 changed files with 24 additions and 25 deletions

View File

@ -109,7 +109,9 @@ void AppearanceWidget::updateTheme(const QString& theme)
if (GUIUtil::getActiveTheme() != newValue) {
QSettings().setValue("theme", newValue);
// Force loading the theme
GUIUtil::loadTheme(nullptr, true);
if (model) {
GUIUtil::loadTheme(model->node(), nullptr, true);
}
}
}

View File

@ -359,7 +359,7 @@ void BitcoinApplication::createWindow(const NetworkStyle *networkStyle)
{
window = new BitcoinGUI(m_node, networkStyle, 0);
GUIUtil::loadTheme(window);
GUIUtil::loadTheme(m_node, window);
pollShutdownTimer = new QTimer(window);
connect(pollShutdownTimer, SIGNAL(timeout()), window, SLOT(detectShutdown()));
@ -419,7 +419,7 @@ void BitcoinApplication::requestShutdown()
// Show a simple window indicating shutdown status
// Do this first as some of the steps may take some time below,
// for example the RPC console may still be executing a command.
shutdownWindow.reset(ShutdownWindow::showShutdownWindow(window));
shutdownWindow.reset(ShutdownWindow::showShutdownWindow(m_node, window));
qDebug() << __func__ << ": Requesting shutdown";
startThread();

View File

@ -15,7 +15,6 @@
#include <base58.h>
#include <chainparams.h>
#include <init.h> // for ShutdownRequested
#include <primitives/transaction.h>
#include <interfaces/node.h>
#include <key_io.h>
@ -1083,7 +1082,7 @@ const bool isValidTheme(const QString& strTheme)
return strTheme == defaultTheme || strTheme == darkThemePrefix || strTheme == traditionalTheme;
}
void loadStyleSheet(QWidget* widget, bool fForceUpdate)
void loadStyleSheet(interfaces::Node& node, QWidget* widget, bool fForceUpdate)
{
AssertLockNotHeld(cs_css);
LOCK(cs_css);
@ -1196,8 +1195,8 @@ void loadStyleSheet(QWidget* widget, bool fForceUpdate)
++it;
}
if (!ShutdownRequested() && fDebugCustomStyleSheets && !fForceUpdate) {
QTimer::singleShot(200, [] { loadStyleSheet(); });
if (!node.shutdownRequested() && fDebugCustomStyleSheets && !fForceUpdate) {
QTimer::singleShot(200, [&] { loadStyleSheet(node); });
}
}
@ -1713,9 +1712,9 @@ bool dashThemeActive()
return theme != traditionalTheme;
}
void loadTheme(QWidget* widget, bool fForce)
void loadTheme(interfaces::Node& node, QWidget* widget, bool fForce)
{
loadStyleSheet(widget, fForce);
loadStyleSheet(node, widget, fForce);
updateFonts();
updateMacFocusRects();
}

View File

@ -278,7 +278,7 @@ namespace GUIUtil
/** Updates the widgets stylesheet and adds it to the list of ui debug elements.
Beeing on that list means the stylesheet of the widget gets updated if the
related css files has been changed if -debug-ui mode is active. */
void loadStyleSheet(QWidget* widget = nullptr, bool fForceUpdate = false);
void loadStyleSheet(interfaces::Node& node, QWidget* widget = nullptr, bool fForceUpdate = false);
enum class FontFamily {
SystemDefault,
@ -363,7 +363,7 @@ namespace GUIUtil
bool dashThemeActive();
/** Load the theme and update all UI elements according to the appearance settings. */
void loadTheme(QWidget* widget = nullptr, bool fForce = false);
void loadTheme(interfaces::Node& node, QWidget* widget = nullptr, bool fForce = false);
/** Disable the OS default focus rect for macOS because we have custom focus rects
* set in the css files */

View File

@ -207,7 +207,7 @@ bool Intro::pickDataDirectory(interfaces::Node& node)
/* Let the user choose one */
Intro intro;
GUIUtil::disableMacFocusRect(&intro);
GUIUtil::loadStyleSheet(&intro);
GUIUtil::loadStyleSheet(node, &intro);
intro.setDataDirectory(dataDirDefaultCurrent);
intro.setWindowIcon(QIcon(":icons/dash"));

View File

@ -5,7 +5,6 @@
#include <clientversion.h>
#include <coins.h>
#include <qt/guiutil.h>
#include <init.h>
#include <netbase.h>
#include <qt/walletmodel.h>
@ -145,7 +144,7 @@ void MasternodeList::updateDIP3ListScheduled()
TRY_LOCK(cs_dip3list, fLockAcquired);
if (!fLockAcquired) return;
if (!clientModel || ShutdownRequested()) {
if (!clientModel || clientModel->node().shutdownRequested()) {
return;
}
@ -172,7 +171,7 @@ void MasternodeList::updateDIP3ListScheduled()
void MasternodeList::updateDIP3List()
{
if (!clientModel || ShutdownRequested()) {
if (!clientModel || clientModel->node().shutdownRequested()) {
return;
}

View File

@ -9,7 +9,6 @@
#include <qt/bitcoinunits.h>
#include <qt/clientmodel.h>
#include <qt/guiutil.h>
#include <init.h>
#include <qt/optionsmodel.h>
#include <qt/transactionfilterproxy.h>
#include <qt/transactiontablemodel.h>
@ -318,7 +317,7 @@ void OverviewPage::showOutOfSyncWarning(bool fShow)
void OverviewPage::updateCoinJoinProgress()
{
if (ShutdownRequested() || !walletModel || !clientModel || !clientModel->masternodeSync().isBlockchainSynced()) return;
if (!walletModel || !clientModel || clientModel->node().shutdownRequested() || !clientModel->masternodeSync().isBlockchainSynced()) return;
QString strAmountAndRounds;
QString strCoinJoinAmount = BitcoinUnits::formatHtmlWithUnit(nDisplayUnit, clientModel->coinJoinOptions().getAmount() * COIN, false, BitcoinUnits::separatorAlways);
@ -434,7 +433,7 @@ void OverviewPage::coinJoinStatus(bool fForce)
{
if (!walletModel || !clientModel) return;
if (!fForce && (ShutdownRequested() || !clientModel->masternodeSync().isBlockchainSynced())) return;
if (!fForce && (clientModel->node().shutdownRequested() || !clientModel->masternodeSync().isBlockchainSynced())) return;
// Disable any PS UI for masternode or when autobackup is disabled or failed for whatever reason
if (fMasternodeMode || nWalletBackups <= 0) {

View File

@ -723,7 +723,7 @@ void RPCConsole::setClientModel(ClientModel *model)
autoCompleter = new QCompleter(wordList, this);
autoCompleter->popup()->setItemDelegate(new QStyledItemDelegate(this));
autoCompleter->popup()->setObjectName("rpcAutoCompleter");
GUIUtil::loadStyleSheet(autoCompleter->popup());
GUIUtil::loadStyleSheet(node, autoCompleter->popup());
autoCompleter->setModelSorting(QCompleter::CaseSensitivelySortedModel);
ui->lineEdit->setCompleter(autoCompleter);
autoCompleter->popup()->installEventFilter(this);

View File

@ -185,12 +185,12 @@ void HelpMessageDialog::on_okButton_accepted()
/** "Shutdown" window */
ShutdownWindow::ShutdownWindow(QWidget *parent, Qt::WindowFlags f):
ShutdownWindow::ShutdownWindow(interfaces::Node& node, QWidget *parent, Qt::WindowFlags f):
QWidget(parent, f)
{
setObjectName("ShutdownWindow");
GUIUtil::loadStyleSheet(this);
GUIUtil::loadStyleSheet(node, this);
QVBoxLayout *layout = new QVBoxLayout();
layout->addWidget(new QLabel(
@ -201,13 +201,13 @@ ShutdownWindow::ShutdownWindow(QWidget *parent, Qt::WindowFlags f):
GUIUtil::updateFonts();
}
QWidget *ShutdownWindow::showShutdownWindow(BitcoinGUI *window)
QWidget *ShutdownWindow::showShutdownWindow(interfaces::Node& node, BitcoinGUI *window)
{
if (!window)
return nullptr;
// Show a simple window indicating shutdown status
QWidget *shutdownWindow = new ShutdownWindow();
QWidget *shutdownWindow = new ShutdownWindow(node);
shutdownWindow->setWindowTitle(window->windowTitle());
// Center shutdown window at where main window was

View File

@ -51,8 +51,8 @@ class ShutdownWindow : public QWidget
Q_OBJECT
public:
explicit ShutdownWindow(QWidget *parent=0, Qt::WindowFlags f=0);
static QWidget *showShutdownWindow(BitcoinGUI *window);
explicit ShutdownWindow(interfaces::Node& node, QWidget *parent=0, Qt::WindowFlags f=0);
static QWidget *showShutdownWindow(interfaces::Node& node, BitcoinGUI *window);
protected:
void closeEvent(QCloseEvent *event);