Changeset 3390

Show
Ignore:
Timestamp:
02/09/08 17:11:54
Author:
pvanhoof
Message:

Fixed potential cyclic referencing

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libtinymailui-gtk/tny-gtk-folder-store-tree-model.c

    r3385 r3390  
    401401} AccNotYetReadyInfo; 
    402402 
     403static void  
     404notify_signal_slots (gpointer user_data, GObject *instance) 
     405{ 
     406        TnyGtkFolderStoreTreeModel *self = (TnyGtkFolderStoreTreeModel *) user_data; 
     407        int i=0; 
     408 
     409        for (i=0; i < self->signals->len; i++) { 
     410                SignalSlot *slot = (SignalSlot *) self->signals->pdata[i]; 
     411                if (slot->instance == instance) 
     412                        slot->instance = NULL; 
     413        } 
     414} 
     415 
    403416static gboolean 
    404417account_was_not_yet_ready_idle (gpointer user_data) 
     
    412425 
    413426                slot = g_slice_new (SignalSlot); 
    414                 slot->instance = g_object_ref (info->account)
     427                slot->instance = (GObject *) info->account
    415428                slot->handler_id = g_signal_connect (info->account, "connection-status-changed", 
    416429                        G_CALLBACK (tny_gtk_folder_store_tree_model_on_constatus_changed), info->self); 
     430                g_object_weak_ref (G_OBJECT (info->account), notify_signal_slots, info->self); 
    417431                g_ptr_array_add (info->self->signals, slot); 
    418432 
    419433                slot = g_slice_new (SignalSlot); 
    420                 slot->instance = g_object_ref (info->account)
     434                slot->instance = (GObject *) info->account
    421435                slot->handler_id = g_signal_connect (info->account, "changed", 
    422436                        G_CALLBACK (tny_gtk_folder_store_tree_model_on_changed), info->self); 
     437                g_object_weak_ref (G_OBJECT (info->account), notify_signal_slots, info->self); 
    423438                g_ptr_array_add (info->self->signals, slot); 
    424439 
     
    445460        g_slice_free (AccNotYetReadyInfo, user_data); 
    446461} 
     462 
    447463 
    448464static void 
     
    484500 
    485501                        slot = g_slice_new (SignalSlot); 
    486                         slot->instance = g_object_ref (folder_store); 
     502 
     503                        slot->instance = (GObject *)folder_store;  
    487504                        slot->handler_id = g_signal_connect (folder_store, "connection-status-changed", 
    488505                                G_CALLBACK (tny_gtk_folder_store_tree_model_on_constatus_changed), self); 
     506                        g_object_weak_ref (G_OBJECT (folder_store), notify_signal_slots, self); 
    489507                        g_ptr_array_add (self->signals, slot); 
    490508 
    491509                        slot = g_slice_new (SignalSlot); 
    492                         slot->instance = g_object_ref (folder_store); 
     510                        slot->instance = (GObject *)folder_store; //g_object_ref (folder_store); 
    493511                        slot->handler_id = g_signal_connect (folder_store, "changed", 
    494512                                G_CALLBACK (tny_gtk_folder_store_tree_model_on_changed), self); 
     513                        g_object_weak_ref (G_OBJECT (folder_store), notify_signal_slots, self); 
    495514                        g_ptr_array_add (self->signals, slot); 
    496515                } 
     
    551570        for (i = 0; i < me->signals->len; i++) { 
    552571                SignalSlot *slot = (SignalSlot *) me->signals->pdata [i]; 
    553                 g_signal_handler_disconnect (slot->instance, slot->handler_id); 
    554                 g_object_unref (slot->instance); 
     572                if (slot->instance) { 
     573                        g_signal_handler_disconnect (slot->instance, slot->handler_id); 
     574                        g_object_weak_unref (G_OBJECT (slot->instance), notify_signal_slots, object); 
     575                } 
    555576                g_slice_free (SignalSlot, slot); 
    556577        }