Enlightenment CVS committal

Author  : rbdpngn
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/lib


Modified Files:
        ewl_widget.h ewl_callback.c ewl_callback.h 


Log Message:
Adjust iterations over the callback list as items are added or removed in the
callbacks.

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_widget.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -3 -r1.18 -r1.19
--- ewl_widget.h        20 Oct 2005 04:33:47 -0000      1.18
+++ ewl_widget.h        4 Nov 2005 04:34:48 -0000       1.19
@@ -32,6 +32,7 @@
        void **list;
        unsigned short mask;
        unsigned short len;
+       unsigned short index;
 };
 
 typedef struct Ewl_Color_Set Ewl_Color_Set;
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_callback.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -3 -r1.8 -r1.9
--- ewl_callback.c      2 Nov 2005 18:23:21 -0000       1.8
+++ ewl_callback.c      4 Nov 2005 04:34:48 -0000       1.9
@@ -165,6 +165,9 @@
        w->callbacks[t].list = realloc(w->callbacks[t].list, 
                                        w->callbacks[t].len * sizeof(void *));
 
+       if (pos < EWL_CALLBACK_POS(w, t))
+               EWL_CALLBACK_POS(w, t)--;
+
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
@@ -221,6 +224,10 @@
                }
                w->callbacks[t].list[pos] = cb;
        }
+
+       if (pos < EWL_CALLBACK_POS(w, t))
+               EWL_CALLBACK_POS(w, t)++;
+
        DRETURN_INT(cb->id, DLEVEL_STABLE);
 }
 
@@ -384,9 +391,8 @@
 ewl_callback_call_with_event_data(Ewl_Widget *w, Ewl_Callback_Type t,
                                  void *ev_data)
 {
-       Ewl_Callback *cb;
+       Ewl_Callback *cb, *oldcb;
        Ewl_Widget *parent, *top = NULL;
-       int i;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("w", w);
@@ -430,11 +436,16 @@
         * Loop through and execute each of the callbacks of a certain type for
         * the specified widget.
         */
-       for (i = 0; i < EWL_CALLBACK_LEN(w, t); i++)
+       EWL_CALLBACK_POS(w, t) = 0;
+       while (EWL_CALLBACK_POS(w, t) < EWL_CALLBACK_LEN(w, t))
        {
-               cb = EWL_CALLBACK_GET(w, t, i);
+               oldcb = cb = EWL_CALLBACK_GET(w, t, EWL_CALLBACK_POS(w, t));
                if (cb->func)
                        cb->func(w, ev_data, cb->user_data);
+               cb = EWL_CALLBACK_GET(w, t, EWL_CALLBACK_POS(w, t));
+
+               if (cb == oldcb)
+                       EWL_CALLBACK_POS(w, t)++;
        }
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_callback.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- ewl_callback.h      16 Sep 2005 19:00:24 -0000      1.4
+++ ewl_callback.h      4 Nov 2005 04:34:48 -0000       1.5
@@ -66,6 +66,12 @@
 #define EWL_CALLBACK_LEN(w, t) (w->callbacks[t].len)
 
 /**
+ * @def EWL_CALLBACK_POS(w, t)
+ * Retrives the current callback position from a widget for an event type.
+ */
+#define EWL_CALLBACK_POS(w, t) w->callbacks[t].index
+
+/**
  * @def EWL_CALLBACK_GET(w, t, i)
  * Retrives the callback struct at the given position
  */




-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to