Changeset 6858


Ignore:
Timestamp:
Oct 6, 2008, 8:35:48 PM (13 years ago)
Author:
charles
Message:

(gtk) fix prefs dialog crash when closing the dialog immediately after changing a spinbox value, reported by wereHamster

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/tr-prefs.c

    r6825 r6858  
    198198struct spin_idle_data
    199199{
     200    guint       tag;
    200201    gpointer    core;
    201202    GTimer *    last_change;
     
    211212}
    212213
     214static void
     215onSpinDestroyed( gpointer     tag,
     216                 GObject    * details UNUSED )
     217{
     218    g_source_remove( GPOINTER_TO_UINT( tag ) );
     219}
     220
    213221static gboolean
    214222spun_cb_idle( gpointer spin )
    215223{
    216     gboolean                keep_waiting = TRUE;
    217     GObject *               o = G_OBJECT( spin );
     224    gboolean keep_waiting = TRUE;
     225    GObject * o = G_OBJECT( spin );
    218226    struct spin_idle_data * data = g_object_get_data( o, IDLE_DATA );
    219227
     
    228236
    229237        /* cleanup */
     238        g_object_weak_unref( o, onSpinDestroyed, GUINT_TO_POINTER( data->tag ) );
    230239        g_object_set_data( o, IDLE_DATA, NULL );
    231240        keep_waiting = FALSE;
     
    249258        data->core = core;
    250259        data->last_change = g_timer_new( );
     260        data->tag = g_timeout_add( 100, spun_cb_idle, w );
    251261        g_object_set_data_full( o, IDLE_DATA, data, spin_idle_data_free );
    252         g_timeout_add( 100, spun_cb_idle, w );
     262        g_object_weak_ref( o, onSpinDestroyed, GUINT_TO_POINTER( data->tag ) );
    253263    }
    254264    g_timer_start( data->last_change );
Note: See TracChangeset for help on using the changeset viewer.