Hello all,

The attached patch properly stops the autorepeat timer when the mouse
is up.  It sets the 'repeating' flag properly and acts accordingly.

Without the patch, clicking an elm_button with autorepeat enabled
rather quickly will cause the repeated events to be generated forever.
 The timing of this race condition is quite interesting.  And yes, it
was my careless autorepeat implementation.

Please have a look at the patch and correct it when you see fit.
Thanks in advance.


brian

-- 
brian
------------------

Cool-Karaoke - The smallest recording studio, in your palm, open-sourced
http://cool-idea.com.tw/

iMaGiNaTiOn iS mOrE iMpOrTaNt tHaN kNoWlEdGe
Index: elementary/src/lib/elm_button.c
===================================================================
--- elementary/src/lib/elm_button.c     (revision 47825)
+++ elementary/src/lib/elm_button.c     (working copy)
@@ -146,6 +146,12 @@
 {
    Widget_Data *wd = elm_widget_data_get(data);
    if (!wd) return;
+   if (wd->timer)
+     {
+       ecore_timer_del(wd->timer);
+       wd->timer = NULL;
+     }
+   wd->repeating = EINA_FALSE;
    evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
    _signal_unpressed(data, obj, emission, source); /* safe guard when the 
theme does not emit the 'unpress' signal */
 }
@@ -157,6 +163,11 @@
    if (!wd) return ECORE_CALLBACK_CANCEL;
 
    evas_object_smart_callback_call(data, SIG_REPEATED, NULL);
+   if (!wd->repeating)
+     {
+       wd->timer = NULL;
+       return ECORE_CALLBACK_CANCEL;
+     }
 
    return ECORE_CALLBACK_RENEW;
 }
@@ -167,9 +178,10 @@
    Widget_Data *wd = elm_widget_data_get(data);
    if (!wd) return ECORE_CALLBACK_CANCEL;
 
+   if (wd->timer) ecore_timer_del(wd->timer);
+   wd->repeating = EINA_TRUE;
    _autorepeat_send(data);
    wd->timer = ecore_timer_add(wd->ar_interval, _autorepeat_send, data);
-   wd->repeating = 1;
 
    return ECORE_CALLBACK_CANCEL;
 }
@@ -180,7 +192,7 @@
    Widget_Data *wd = elm_widget_data_get(data);
    if (!wd) return;
 
-   if (wd->autorepeat)
+   if (wd->autorepeat && !wd->repeating)
      {
        if (wd->ar_threshold <= 0.0)
          _autorepeat_initial_send(data); /* call immediately */
@@ -194,14 +206,14 @@
 {
    Widget_Data *wd = elm_widget_data_get(data);
    if (!wd) return;
-   evas_object_smart_callback_call(data, SIG_UNPRESSED, NULL);
 
    if (wd->timer)
      {
        ecore_timer_del(wd->timer);
        wd->timer = NULL;
      }
-   wd->repeating = 0;
+   wd->repeating = EINA_FALSE;
+   evas_object_smart_callback_call(data, SIG_UNPRESSED, NULL);
 }
 
 /**
@@ -352,6 +364,7 @@
         wd->timer = NULL;
      }
    wd->autorepeat = on;
+   wd->repeating = EINA_FALSE;
 }
 
 /**
@@ -392,13 +405,8 @@
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
    if (wd->ar_interval == t) return;
-   if (wd->timer)
-     {
-       ecore_timer_del(wd->timer);
-       wd->timer = NULL;
-     }
+
    wd->ar_interval = t;
-   if (wd->repeating)
-     wd->timer = ecore_timer_add(t, _autorepeat_send, obj);
+   if (wd->repeating && wd->timer) ecore_timer_interval_set(wd->timer, t);
 }
 
------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to