From aa11a241639094818f43898c9ad8910e689c1d8b Mon Sep 17 00:00:00 2001 From: pajlada Date: Sun, 17 Dec 2023 12:53:06 +0100 Subject: [PATCH] fix: UserInfoPopup now requires a split as its parent (#5034) Co-authored-by: Nerixyz --- CHANGELOG.md | 1 + src/controllers/commands/builtin/Misc.cpp | 6 ++---- src/widgets/dialogs/UserInfoPopup.cpp | 7 +++---- src/widgets/dialogs/UserInfoPopup.hpp | 7 +++++-- src/widgets/helper/ChannelView.cpp | 7 +++---- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ef6f073a..dc91a19d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,7 @@ - Bugfix: Hide the Usercard button in the User Info Popup when in special channels. (#4972) - Bugfix: Fixed support for Windows 11 Snap layouts. (#4994) - Bugfix: Fixed some windows appearing between screens. (#4797) +- Bugfix: Fixed a crash that could occur when using certain features in a Usercard after closing the split from which it was created. (#5034) - Bugfix: Fixed a bug on Wayland where tooltips would spawn as separate windows instead of behaving like tooltips. (#4998) - Bugfix: Fixes to section deletion in text input fields. (#5013) - Bugfix: Show user text input within watch streak notices. (#5029) diff --git a/src/controllers/commands/builtin/Misc.cpp b/src/controllers/commands/builtin/Misc.cpp index 7100e7776..870e5b342 100644 --- a/src/controllers/commands/builtin/Misc.cpp +++ b/src/controllers/commands/builtin/Misc.cpp @@ -616,10 +616,8 @@ QString openUsercard(const CommandContext &ctx) "should be open."); } - auto *userPopup = new UserInfoPopup( - getSettings()->autoCloseUserPopup, - static_cast(&(getApp()->windows->getMainWindow())), - currentSplit); + auto *userPopup = + new UserInfoPopup(getSettings()->autoCloseUserPopup, currentSplit); userPopup->setData(userName, channel); userPopup->moveTo(QCursor::pos(), widgets::BoundsChecking::CursorPosition); userPopup->show(); diff --git a/src/widgets/dialogs/UserInfoPopup.cpp b/src/widgets/dialogs/UserInfoPopup.cpp index 5bf44c5e9..79fd11c8e 100644 --- a/src/widgets/dialogs/UserInfoPopup.cpp +++ b/src/widgets/dialogs/UserInfoPopup.cpp @@ -1,4 +1,4 @@ -#include "UserInfoPopup.hpp" +#include "widgets/dialogs/UserInfoPopup.hpp" #include "Application.hpp" #include "common/Channel.hpp" @@ -134,9 +134,8 @@ namespace { } // namespace -UserInfoPopup::UserInfoPopup(bool closeAutomatically, QWidget *parent, - Split *split) - : DraggablePopup(closeAutomatically, parent) +UserInfoPopup::UserInfoPopup(bool closeAutomatically, Split *split) + : DraggablePopup(closeAutomatically, split) , split_(split) , closeAutomatically_(closeAutomatically) { diff --git a/src/widgets/dialogs/UserInfoPopup.hpp b/src/widgets/dialogs/UserInfoPopup.hpp index e22f6d2cf..cff57fdaf 100644 --- a/src/widgets/dialogs/UserInfoPopup.hpp +++ b/src/widgets/dialogs/UserInfoPopup.hpp @@ -23,8 +23,11 @@ class UserInfoPopup final : public DraggablePopup Q_OBJECT public: - UserInfoPopup(bool closeAutomatically, QWidget *parent, - Split *split = nullptr); + /** + * @param closeAutomatically Decides whether the popup should close when it loses focus + * @param split Will be used as the popup's parent. Must not be null + */ + UserInfoPopup(bool closeAutomatically, Split *split); void setData(const QString &name, const ChannelPtr &channel); void setData(const QString &name, const ChannelPtr &contextChannel, diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index a333e89e1..cd55d8df7 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -2580,10 +2580,9 @@ void ChannelView::hideEvent(QHideEvent * /*event*/) void ChannelView::showUserInfoPopup(const QString &userName, QString alternativePopoutChannel) { - auto *userCardParent = - static_cast(&(getApp()->windows->getMainWindow())); - auto *userPopup = new UserInfoPopup(getSettings()->autoCloseUserPopup, - userCardParent, this->split_); + assert(this->split_ != nullptr); + auto *userPopup = + new UserInfoPopup(getSettings()->autoCloseUserPopup, this->split_); auto contextChannel = getApp()->twitch->getChannelOrEmpty(alternativePopoutChannel);