blob: f5ec632675132cede05b41fec4de64b2a3c3004c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
From a63bc75301a3c4a74eb2723e34606ac40e473d27 Mon Sep 17 00:00:00 2001
From: Oliver Sedlbauer <os@dev.tdt.de>
Date: Fri, 6 Mar 2026 10:59:44 +0100
Subject: [PATCH] plugin_layout: prevent concurrent layout switches
In plugin_layout, switching layouts while a switch is already in progress
corrupts widget timer state and causes a segfault. Use a static lock to
skip layout switches that arrive while one is already in progress.
Signed-off-by: Oliver Sedlbauer <os@dev.tdt.de>
---
plugin_layout.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
--- a/plugin_layout.c
+++ b/plugin_layout.c
@@ -251,15 +251,25 @@ static int my_hide_layout(const Layout *
static int my_switch_layout(const int groupIdx, const int layoutIdx)
{
+ static int switching = 0;
+ if (switching) {
+ my_info("Skipping layout switch, already in progress");
+ return 0;
+ }
+ switching = 1;
- if (groupIdx < 0 || groupIdx >= plugin->groupNb)
- return -1;
+ if (groupIdx < 0 || groupIdx >= plugin->groupNb) {
+ switching = 0;
+ return -1;
+ }
LayoutGroup *oldGroup = plugin->currentGroup;
LayoutGroup *newGroup = plugin->groups[groupIdx];
- if (layoutIdx < 0 || layoutIdx >= newGroup->layoutNb)
- return -1;
+ if (layoutIdx < 0 || layoutIdx >= newGroup->layoutNb) {
+ switching = 0;
+ return -1;
+ }
Layout *oldLayout = plugin->currentLayout;
Layout *newLayout = newGroup->layouts[layoutIdx];
@@ -292,7 +302,7 @@ static int my_switch_layout(const int gr
action_trigger(newLayout->firstAction, "onenter");
}
-
+ switching = 0;
return status;
}
|