From 71fe3d916576d062f072e2b9e1b5669d247414e9 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Fri, 13 Jun 2025 20:12:32 -0700 Subject: [PATCH] x11/panelwindow: do not look up engine generation in ~XPanelWindow() Looking up engine generation in the destructor causes occasional crashes. This commit caches it to prevent that from happening. --- src/x11/panel_window.cpp | 12 ++++++++---- src/x11/panel_window.hpp | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/x11/panel_window.cpp b/src/x11/panel_window.cpp index 9ffbeb50..ef271b58 100644 --- a/src/x11/panel_window.cpp +++ b/src/x11/panel_window.cpp @@ -40,17 +40,20 @@ public: } void addPanel(XPanelWindow* panel) { - auto& panels = this->mPanels[EngineGeneration::findObjectGeneration(panel)]; + panel->engineGeneration = EngineGeneration::findObjectGeneration(panel); + auto& panels = this->mPanels[panel->engineGeneration]; if (!panels.contains(panel)) { panels.push_back(panel); } } void removePanel(XPanelWindow* panel) { - auto& panels = this->mPanels[EngineGeneration::findObjectGeneration(panel)]; + if (!panel->engineGeneration) return; + + auto& panels = this->mPanels[panel->engineGeneration]; if (panels.removeOne(panel)) { if (panels.isEmpty()) { - this->mPanels.erase(EngineGeneration::findObjectGeneration(panel)); + this->mPanels.erase(panel->engineGeneration); } // from the bottom up, update all panels @@ -61,7 +64,8 @@ public: } void updateLowerDimensions(XPanelWindow* exclude) { - auto& panels = this->mPanels[EngineGeneration::findObjectGeneration(exclude)]; + if (!exclude->engineGeneration) return; + auto& panels = this->mPanels[exclude->engineGeneration]; // update all panels lower than the one we start from auto found = false; diff --git a/src/x11/panel_window.hpp b/src/x11/panel_window.hpp index d8cc9661..c6c1de77 100644 --- a/src/x11/panel_window.hpp +++ b/src/x11/panel_window.hpp @@ -98,6 +98,7 @@ private: Margins mMargins; qint32 mExclusiveZone = 0; ExclusionMode::Enum mExclusionMode = ExclusionMode::Auto; + EngineGeneration* knownGeneration = nullptr; QRect lastScreenVirtualGeometry; XPanelEventFilter eventFilter;