From 2b53fe0e65f556c2fb8957ffe16b1b71d2861c32 Mon Sep 17 00:00:00 2001 From: Hoshino Lina Date: Tue, 23 Dec 2025 23:24:19 +0900 Subject: [PATCH] frontend: Fix QSystemTrayIcon and QMenu delete order QSystemTrayIcon holds a non-owning pointer to the QMenu, so it needs to be deleted first. Fixes: #12948 --- frontend/widgets/OBSBasic.cpp | 1 + frontend/widgets/OBSBasic.hpp | 2 +- frontend/widgets/OBSBasic_SysTray.cpp | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/widgets/OBSBasic.cpp b/frontend/widgets/OBSBasic.cpp index eae813d2d..69aff5b17 100644 --- a/frontend/widgets/OBSBasic.cpp +++ b/frontend/widgets/OBSBasic.cpp @@ -1415,6 +1415,7 @@ void OBSBasic::applicationShutdown() noexcept delete deinterlaceMenu; delete perSceneTransitionMenu; delete shortcutFilter; + delete trayIcon; delete trayMenu; delete programOptions; delete program; diff --git a/frontend/widgets/OBSBasic.hpp b/frontend/widgets/OBSBasic.hpp index e817a60ac..30d222b93 100644 --- a/frontend/widgets/OBSBasic.hpp +++ b/frontend/widgets/OBSBasic.hpp @@ -1471,7 +1471,7 @@ signals: * ------------------------------------- */ private: - QScopedPointer trayIcon; + QPointer trayIcon; QPointer sysTrayStream; QPointer sysTrayRecord; QPointer sysTrayReplayBuffer; diff --git a/frontend/widgets/OBSBasic_SysTray.cpp b/frontend/widgets/OBSBasic_SysTray.cpp index 383fe6330..e1d81501f 100644 --- a/frontend/widgets/OBSBasic_SysTray.cpp +++ b/frontend/widgets/OBSBasic_SysTray.cpp @@ -29,7 +29,7 @@ void OBSBasic::SystemTrayInit() #else QIcon trayIconFile = QIcon(":/res/images/obs.png"); #endif - trayIcon.reset(new QSystemTrayIcon(QIcon::fromTheme("obs-tray", trayIconFile), this)); + trayIcon = new QSystemTrayIcon(QIcon::fromTheme("obs-tray", trayIconFile), this); trayIcon->setToolTip("OBS Studio"); showHide = new QAction(QTStr("Basic.SystemTray.Show"), trayIcon.data());