ShutdownWindow::showShutdownWindow just needs a widget to center the shutdown window and to borrow its title.
gui: Break trivial circular dependencies #18036
pull promag wants to merge 2 commits into bitcoin:master from promag:2020-01-utilitydialog changing 5 files +15 −19-
promag commented at 12:56 AM on January 31, 2020: member
- fanquake added the label GUI on Jan 31, 2020
- promag requested review from hebasto on Jan 31, 2020
-
DrahtBot commented at 3:57 AM on January 31, 2020: member
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
Conflicts
Reviewers, this pull request conflicts with the following ones:
- #17966 (qt, refactor: Optimize signal-slot connections logic by hebasto)
- #15768 (gui: Add close window shortcut by IPGlider)
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
-
in test/lint/lint-circular-dependencies.sh:16 in cdd480b484 outdated
12 | @@ -13,7 +13,6 @@ EXPECTED_CIRCULAR_DEPENDENCIES=( 13 | "index/txindex -> validation -> index/txindex" 14 | "policy/fees -> txmempool -> policy/fees" 15 | "qt/addresstablemodel -> qt/walletmodel -> qt/addresstablemodel" 16 | - "qt/bantablemodel -> qt/clientmodel -> qt/bantablemodel" 17 | "qt/bitcoingui -> qt/utilitydialog -> qt/bitcoingui"
promag commented at 7:31 AM on January 31, 2020:Ops, yes.. this was done on top of the other PR and on rebased I've picked the wrong line.
promag commented at 8:03 AM on January 31, 2020:Fixed.
jonasschnelli commented at 7:56 AM on January 31, 2020: contributorNice. Another one. Thanks
utACK cdd480b484b201afa94d0f86bad04b83ac97e011 modulo fix of the
lint-circular-dependencies.shchange https://github.com/bitcoin/bitcoin/pull/18036/files#r373307566promag force-pushed on Jan 31, 2020promag force-pushed on Jan 31, 2020jonasschnelli commented at 8:08 AM on January 31, 2020: contributorMaybe close #18035 and extend the scope here?
gui: Drop BanTableModel dependency to ClientModel 61eb058cc1promag force-pushed on Jan 31, 2020promag renamed this:gui: Drop ShutdownWindow dependency to BitcoinGUI
gui: Break trivial circular dependencies
on Jan 31, 2020promag commented at 8:21 AM on January 31, 2020: member@jonasschnelli Done!
in src/qt/utilitydialog.cpp:151 in 8ec6210a63 outdated
150 | + assert(parent != nullptr); 151 | 152 | // Show a simple window indicating shutdown status 153 | QWidget *shutdownWindow = new ShutdownWindow(); 154 | - shutdownWindow->setWindowTitle(window->windowTitle()); 155 | + shutdownWindow->setWindowTitle(parent->windowTitle());
hebasto commented at 9:28 AM on January 31, 2020:nit: there is no guarantee now, that
parentis a top-level widget.May I suggest a following diff:
diff --git a/src/qt/utilitydialog.cpp b/src/qt/utilitydialog.cpp index 65e8823cb..a1ce8e741 100644 --- a/src/qt/utilitydialog.cpp +++ b/src/qt/utilitydialog.cpp @@ -19,10 +19,12 @@ #include <QCloseEvent> #include <QLabel> +#include <QMainWindow> #include <QRegExp> #include <QTextTable> #include <QTextCursor> #include <QVBoxLayout> +#include <QWidget> /** "Help message" or "About" dialog box */ HelpMessageDialog::HelpMessageDialog(interfaces::Node& node, QWidget *parent, bool about) : @@ -142,16 +144,16 @@ ShutdownWindow::ShutdownWindow(QWidget *parent, Qt::WindowFlags f): setLayout(layout); } -QWidget* ShutdownWindow::showShutdownWindow(QWidget* parent) +QWidget* ShutdownWindow::showShutdownWindow(QMainWindow* window) { - assert(parent != nullptr); + assert(window); // Show a simple window indicating shutdown status QWidget *shutdownWindow = new ShutdownWindow(); - shutdownWindow->setWindowTitle(parent->windowTitle()); + shutdownWindow->setWindowTitle(window->windowTitle()); // Center shutdown window at where main window was - const QPoint global = parent->mapToGlobal(parent->rect().center()); + const QPoint global = window->mapToGlobal(window->rect().center()); shutdownWindow->move(global.x() - shutdownWindow->width() / 2, global.y() - shutdownWindow->height() / 2); shutdownWindow->show(); return shutdownWindow; diff --git a/src/qt/utilitydialog.h b/src/qt/utilitydialog.h index b52c26758..fdf1bd385 100644 --- a/src/qt/utilitydialog.h +++ b/src/qt/utilitydialog.h @@ -6,6 +6,7 @@ #define BITCOIN_QT_UTILITYDIALOG_H #include <QDialog> +#include <QMainWindow> #include <QWidget> namespace interfaces { @@ -44,7 +45,7 @@ class ShutdownWindow : public QWidget public: explicit ShutdownWindow(QWidget *parent=nullptr, Qt::WindowFlags f=Qt::Widget); - static QWidget* showShutdownWindow(QWidget* window); + static QWidget* showShutdownWindow(QMainWindow* window); protected: void closeEvent(QCloseEvent *event
promag commented at 10:29 AM on January 31, 2020:@hebasto considering https://doc.qt.io/qt-5/qwidget.html#top-level-and-child-widgets how about change the assertion to
assert(parent != nullptr && parent->parentWidget() == nullptr);
hebasto commented at 10:54 AM on January 31, 2020:Yes, this will work. But using
QMainWindowas a parameter type seems clearer semantically (asBitcoinGUIis a direct sub-class ofQMainWindow), and makes checkingparent->parentWidget() == nullptrredundant, no?
promag commented at 11:52 AM on January 31, 2020:Now using
QMainWindow, I think it's unnecessary to depend onQMainWindowjust to get the title and rect but at the same time it's no big deal.hebasto commented at 9:30 AM on January 31, 2020: memberACK 8ec6210a63cf6f1cf14caa909b7111e8c3cd9307, tested on Linux Mint 19.3
The only (non-blocking) suggestion is to use
QMainWindowas a parameter type (in 8ec6210a63cf6f1cf14caa909b7111e8c3cd9307 commit).gui: Drop ShutdownWindow dependency to BitcoinGUI 3aee10b80bpromag force-pushed on Jan 31, 2020practicalswift commented at 12:28 PM on January 31, 2020: contributorConcept ACK: very nice to see two circular includes go. Only 14 instances left :)
hebasto approvedhebasto commented at 2:44 PM on January 31, 2020: memberACK 3aee10b80b9d9a0f5172fc2ee75f03a37d5c3863, since previous review only suggested change
QWidget-->QMainWindowfanquake requested review from jonasschnelli on Feb 1, 2020jonasschnelli approvedjonasschnelli commented at 9:07 AM on February 1, 2020: contributorutACK 3aee10b80b9d9a0f5172fc2ee75f03a37d5c3863
jonasschnelli referenced this in commit cadb9d3342 on Feb 1, 2020jonasschnelli merged this on Feb 1, 2020jonasschnelli closed this on Feb 1, 2020promag deleted the branch on Feb 1, 2020MarkLTZ referenced this in commit 7fdadc73fc on Apr 6, 2020MarkLTZ referenced this in commit 8436547baa on Apr 6, 2020Fabcien referenced this in commit d186cd85cb on Dec 18, 2020Fabcien referenced this in commit af80fee649 on Dec 18, 2020DrahtBot locked this on Feb 15, 2022Labels
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-21 21:14 UTC
More mirrored repositories can be found on mirror.b10c.me