From 2fc7fdd91aaaaab6b19d760b7c10b8231df65ee0 Mon Sep 17 00:00:00 2001 From: nerix Date: Sun, 1 Oct 2023 08:40:34 +0200 Subject: [PATCH] Fix empty page added when showing OOB dialog (#4849) --- CHANGELOG.md | 1 + src/widgets/Notebook.cpp | 5 +++++ src/widgets/Notebook.hpp | 2 ++ src/widgets/Window.cpp | 8 ++------ 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d58bfa49a..2852fbc0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ - Bugfix: Fixed input in reply thread popup losing focus when dragging. (#4815) - Bugfix: Fixed the Quick Switcher (CTRL+K) from sometimes showing up on the wrong window. (#4819) - Bugfix: Fixed too much text being copied when copying chat messages. (#4812, #4830, #4839) +- Bugfix: Fixed empty page being added when showing out of bounds dialog. (#4849) - Dev: Fixed UTF16 encoding of `modes` file for the installer. (#4791) - Dev: Temporarily disable High DPI scaling on Qt6 builds on Windows. (#4767) - Dev: Tests now run on Ubuntu 22.04 instead of 20.04 to loosen C++ restrictions in tests. (#4774) diff --git a/src/widgets/Notebook.cpp b/src/widgets/Notebook.cpp index f9f46b765..efc96daf8 100644 --- a/src/widgets/Notebook.cpp +++ b/src/widgets/Notebook.cpp @@ -1439,6 +1439,11 @@ SplitContainer *SplitNotebook::getOrAddSelectedPage() return this->addPage(); } +SplitContainer *SplitNotebook::getSelectedPage() +{ + return dynamic_cast(Notebook::getSelectedPage()); +} + void SplitNotebook::select(QWidget *page, bool focusPage) { // If there's a previously selected page, go through its splits and diff --git a/src/widgets/Notebook.hpp b/src/widgets/Notebook.hpp index e6cd7d62f..c4382582d 100644 --- a/src/widgets/Notebook.hpp +++ b/src/widgets/Notebook.hpp @@ -209,6 +209,8 @@ public: SplitContainer *addPage(bool select = false); SplitContainer *getOrAddSelectedPage(); + /// Returns `nullptr` when no page is selected. + SplitContainer *getSelectedPage(); void select(QWidget *page, bool focusPage = true) override; void themeChangedEvent() override; diff --git a/src/widgets/Window.cpp b/src/widgets/Window.cpp index 39ae451df..0193b4359 100644 --- a/src/widgets/Window.cpp +++ b/src/widgets/Window.cpp @@ -109,7 +109,7 @@ bool Window::event(QEvent *event) } case QEvent::WindowDeactivate: { - auto page = this->notebook_->getOrAddSelectedPage(); + auto *page = this->notebook_->getSelectedPage(); if (page != nullptr) { @@ -119,12 +119,8 @@ bool Window::event(QEvent *event) { split->updateLastReadMessage(); } - } - if (SplitContainer *container = - dynamic_cast(page)) - { - container->hideResizeHandles(); + page->hideResizeHandles(); } } break;