Enlightenment CVS committal Author : ningerso Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src/lib Modified Files: ewl_callback.c Log Message: Fix custom callback type lookup for dispatching callbacks. =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_callback.c,v retrieving revision 1.22 retrieving revision 1.23 diff -u -3 -r1.22 -r1.23 --- ewl_callback.c 24 Jul 2006 23:52:30 -0000 1.22 +++ ewl_callback.c 25 Jul 2006 09:54:37 -0000 1.23 @@ -156,6 +156,7 @@ ewl_callback_insert(Ewl_Widget *w, unsigned int t, Ewl_Callback *cb, unsigned int pos) { + int place; Ewl_Callback *old = NULL; DENTER_FUNCTION(DLEVEL_STABLE); @@ -169,47 +170,52 @@ DRETURN_INT(0, DLEVEL_STABLE); } + if (t > EWL_CALLBACK_MAX) + place = EWL_CALLBACK_MAX; + else + place = t; + /* set direct if possible */ if (!EWL_CALLBACK_LEN(w, t)) { - w->callbacks[t].list = (void *)cb; - w->callbacks[t].len = 1; + w->callbacks[place].list = (void *)cb; + w->callbacks[place].len = 1; EWL_CALLBACK_SET_DIRECT(w, t); DRETURN_INT(cb->id, DLEVEL_STABLE); } - w->callbacks[t].len ++; + w->callbacks[place].len ++; /* if we have a type direct then we need to save off the direct * pointer and set the list to NULL so it'll be allocd' correctly */ - if (w->callbacks[t].mask & EWL_CALLBACK_TYPE_DIRECT) + if (w->callbacks[place].mask & EWL_CALLBACK_TYPE_DIRECT) { - old = (Ewl_Callback *)w->callbacks[t].list; - w->callbacks[t].list = NULL; + old = (Ewl_Callback *)w->callbacks[place].list; + w->callbacks[place].list = NULL; EWL_CALLBACK_SET_NODIRECT(w, t); } - w->callbacks[t].list = realloc(w->callbacks[t].list, - w->callbacks[t].len * sizeof(void *)); + w->callbacks[place].list = realloc(w->callbacks[place].list, + w->callbacks[place].len * sizeof(void *)); /* if old is set this was a direct so we can just set 0, 1 and be * done with it */ if (old) { - w->callbacks[t].list[0] = (!pos ? cb : old); - w->callbacks[t].list[1] = ( pos ? cb : old); + w->callbacks[place].list[0] = (!pos ? cb : old); + w->callbacks[place].list[1] = ( pos ? cb : old); } else { /* only have to move if we aren't at the end (of the * original lenth already */ - if ((int)pos != (w->callbacks[t].len - 1)) + if ((int)pos != (w->callbacks[place].len - 1)) { - memmove(w->callbacks[t].list + (pos + 1), - w->callbacks[t].list + pos, - (w->callbacks[t].len - 1) * sizeof(void *)); + memmove(w->callbacks[place].list + (pos + 1), + w->callbacks[place].list + pos, + (w->callbacks[place].len - 1) * sizeof(void *)); } - w->callbacks[t].list[pos] = cb; + w->callbacks[place].list[pos] = cb; } if (pos < EWL_CALLBACK_POS(w, t)) @@ -273,14 +279,9 @@ DCHECK_TYPE_RET("w", w, EWL_WIDGET_TYPE, 0); if (type < EWL_CALLBACK_MAX) - { cb = alloca(sizeof(Ewl_Callback)); - } else - { cb = alloca(sizeof(Ewl_Callback_Custom)); - EWL_CALLBACK_CUSTOM(cb)->event_id = type; - } cb->func = func; cb->user_data = user_data; @@ -292,6 +293,7 @@ } else { found = NEW(Ewl_Callback_Custom, 1); + EWL_CALLBACK_CUSTOM(found)->event_id = type; } found->func = func; found->user_data = user_data; ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs