summaryrefslogtreecommitdiff
blob: 17a0c70a0fd14eff75f2b61415b471e350642f83 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
From 43c269a377e7b446fb1bb70732835b7395ce9524 Mon Sep 17 00:00:00 2001
From: Danny Baumann <dannybaumann@web.de>
Date: Mon, 25 Jan 2010 06:28:34 +0000
Subject: Fix crash on opening windows.

We must defer match evaluation until window initialization has finished
for all plugins as match evaluation means wrapped function calls.
---
diff --git a/plugins/obs.c b/plugins/obs.c
index a8d67f1..0f5b9d0 100644
--- a/plugins/obs.c
+++ b/plugins/obs.c
@@ -88,6 +88,8 @@ typedef struct _ObsWindow
 {
     int customFactor[MODIFIER_COUNT];
     int matchFactor[MODIFIER_COUNT];
+
+    CompTimeoutHandle updateHandle;
 } ObsWindow;
 
 #define GET_OBS_DISPLAY(d) \
@@ -323,6 +325,22 @@ obsMatchPropertyChanged (CompDisplay *d,
     WRAP (od, d, matchPropertyChanged, obsMatchPropertyChanged);
 }
 
+static Bool
+obsUpdateWindow (void *closure)
+{
+    CompWindow *w = (CompWindow *) closure;
+    int        i;
+
+    OBS_WINDOW (w);
+
+    for (i = 0; i < MODIFIER_COUNT; i++)
+	updatePaintModifier (w, i);
+
+    ow->updateHandle = 0;
+
+    return FALSE;
+}
+
 static CompOption *
 obsGetDisplayOptions (CompPlugin  *p,
 		      CompDisplay *display,
@@ -628,8 +646,8 @@ static CompBool
 obsInitWindow (CompPlugin *p,
 	       CompWindow *w)
 {
-    ObsWindow    *ow;
-    int          i;
+    ObsWindow *ow;
+    int       i;
 
     OBS_SCREEN (w->screen);
 
@@ -643,10 +661,11 @@ obsInitWindow (CompPlugin *p,
 	ow->matchFactor[i]  = 100;
     }
 
-    w->base.privates[os->windowPrivateIndex].ptr = ow;
+    /* defer initializing the factors from window matches as match evalution
+       means wrapped function calls */
+    ow->updateHandle = compAddTimeout (0, 0, obsUpdateWindow, w);
 
-    for (i = 0; i < MODIFIER_COUNT; i++)
-	updatePaintModifier (w, i);
+    w->base.privates[os->windowPrivateIndex].ptr = ow;
 
     return TRUE;
 }
@@ -657,6 +676,9 @@ obsFiniWindow (CompPlugin *p,
 {
     OBS_WINDOW (w);
 
+    if (ow->updateHandle)
+	compRemoveTimeout (ow->updateHandle);
+
     free (ow);
 }
 
--
cgit v0.8.2