Skip to content

Commit 71fe3d9

Browse files
committed
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.
1 parent 517143a commit 71fe3d9

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/x11/panel_window.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,20 @@ class XPanelStack {
4040
}
4141

4242
void addPanel(XPanelWindow* panel) {
43-
auto& panels = this->mPanels[EngineGeneration::findObjectGeneration(panel)];
43+
panel->engineGeneration = EngineGeneration::findObjectGeneration(panel);
44+
auto& panels = this->mPanels[panel->engineGeneration];
4445
if (!panels.contains(panel)) {
4546
panels.push_back(panel);
4647
}
4748
}
4849

4950
void removePanel(XPanelWindow* panel) {
50-
auto& panels = this->mPanels[EngineGeneration::findObjectGeneration(panel)];
51+
if (!panel->engineGeneration) return;
52+
53+
auto& panels = this->mPanels[panel->engineGeneration];
5154
if (panels.removeOne(panel)) {
5255
if (panels.isEmpty()) {
53-
this->mPanels.erase(EngineGeneration::findObjectGeneration(panel));
56+
this->mPanels.erase(panel->engineGeneration);
5457
}
5558

5659
// from the bottom up, update all panels
@@ -61,7 +64,8 @@ class XPanelStack {
6164
}
6265

6366
void updateLowerDimensions(XPanelWindow* exclude) {
64-
auto& panels = this->mPanels[EngineGeneration::findObjectGeneration(exclude)];
67+
if (!exclude->engineGeneration) return;
68+
auto& panels = this->mPanels[exclude->engineGeneration];
6569

6670
// update all panels lower than the one we start from
6771
auto found = false;

src/x11/panel_window.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ private slots:
9898
Margins mMargins;
9999
qint32 mExclusiveZone = 0;
100100
ExclusionMode::Enum mExclusionMode = ExclusionMode::Auto;
101+
EngineGeneration* knownGeneration = nullptr;
101102

102103
QRect lastScreenVirtualGeometry;
103104
XPanelEventFilter eventFilter;

0 commit comments

Comments
 (0)