This is incase a window is destroyed between the initWindow and
handleTimeouts call, which might not be possible, but seems to be the right
thing to do anyways? I moved the callback to a seperate function to avoid
the possiblity of another call to ApplyRules from clearing timeout handle
before it is called. This was written because of this crash (though I have
not yet confirmed whether that is the problem, or whether it fixes it):

#0  0x00007fab3157f5d5 in waitpid () from /lib64/libc.so.6
#1  0x00007fab3151b861 in ?? () from /lib64/libc.so.6
#2  0x00007fab2f655a39 in ?? () from /usr/lib64/compiz/libcrashhandler.so
#3  <signal handler called>
#4  0x00007fab2a27fb21 in ?? () from /usr/lib64/compiz/libwinrules.so
#5  0x00007fab2a2801bb in ?? () from /usr/lib64/compiz/libwinrules.so
#6  0x000000000040f41b in handleTimeouts ()
#7  0x0000000000412cd6 in eventLoop ()
#8  0x000000000040d608 in main ()

from http://forum.compiz-fusion.org/showthread.php?p=71367

Joel.

-----

>From 07ad1c5da3d4c8e0b4f03bbf0c63da39d5611455 Mon Sep 17 00:00:00 2001
From: Joel Bosveld <joel.bosv...@gmail.com>
Date: Wed, 25 Feb 2009 12:14:03 +0900
Subject: [PATCH] Remove compTimeout on window destroy

---
 winrules.c |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/winrules.c b/winrules.c
index 65ef417..fb1488e 100644
--- a/winrules.c
+++ b/winrules.c
@@ -53,6 +53,8 @@ typedef struct _WinrulesWindow {

     Bool oldInputHint;
     Bool hasAlpha;
+
+    CompTimeoutHandle handle;
 } WinrulesWindow;

 typedef struct _WinrulesDisplay {
@@ -464,9 +466,8 @@ winrulesSetScreenOption (CompPlugin *plugin,
 }

 static Bool
-winrulesApplyRules (void *closure)
+winrulesApplyRules (CompWindow *w)
 {
-    CompWindow *w = (CompWindow *) closure;
     int        width, height;

     winrulesUpdateState (w,
@@ -527,6 +528,17 @@ winrulesApplyRules (void *closure)
     return FALSE;
 }

+static Bool
+winrulesApplyRulesTimeout (void *closure)
+{
+    CompWindow *w = (CompWindow *) closure;
+
+    WINRULES_WINDOW (w);
+    ww->handle = 0;
+
+    return winrulesApplyRules (w);
+}
+
 static void
 winrulesHandleEvent (CompDisplay *d,
                      XEvent      *event)
@@ -736,7 +748,7 @@ winrulesInitWindow (CompPlugin *p,

     w->base.privates[ws->windowPrivateIndex].ptr = ww;

-    compAddTimeout (0, 0, winrulesApplyRules, w);
+    ww->handle = compAddTimeout (0, 0, winrulesApplyRulesTimeout, w);

     return TRUE;
 }
@@ -747,6 +759,8 @@ winrulesFiniWindow (CompPlugin *p,
 {
     WINRULES_WINDOW (w);

+    if(ww->handle) compRemoveTimeout (ww->handle);
+
     free (ww);
 }

-- 
1.5.4.3
_______________________________________________
Dev mailing list
Dev@lists.compiz-fusion.org
http://lists.compiz-fusion.org/mailman/listinfo/dev

Reply via email to