From 43c269a377e7b446fb1bb70732835b7395ce9524 Mon Sep 17 00:00:00 2001 From: Danny Baumann Date: Mon, 25 Jan 2010 07:28:34 +0100 Subject: [PATCH] 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. --- plugins/obs.c | 32 +++++++++++++++++++++++++++----- 1 files changed, 27 insertions(+), 5 deletions(-) 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); } -- 1.6.6