Changeset 1913

Show
Ignore:
Timestamp:
05/08/07 13:22:08
Author:
pvanhoof
Message:

Removing items bug

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libtinymail-camel/tny-camel-folder.c

    r1907 r1913  
    8080        TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 
    8181        TnyIterator *iter; 
     82        TnyList *list; 
    8283 
    8384        if (!priv->sobservers) 
     
    8586 
    8687        g_static_rec_mutex_lock (priv->obs_lock); 
    87  
    88         iter = tny_list_create_iterator (priv->sobservers); 
     88        list = tny_list_copy (priv->sobservers); 
     89        g_static_rec_mutex_unlock (priv->obs_lock); 
     90 
     91        iter = tny_list_create_iterator (list); 
     92 
    8993        while (!tny_iterator_is_done (iter)) 
    9094        { 
     
    96100        g_object_unref (G_OBJECT (iter)); 
    97101 
    98         g_static_rec_mutex_unlock (priv->obs_lock); 
     102        g_object_unref (list); 
    99103 
    100104} 
     
    105109        TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 
    106110        TnyIterator *iter; 
     111        TnyList *list; 
    107112 
    108113        if (!priv->observers) 
     
    110115 
    111116        g_static_rec_mutex_lock (priv->obs_lock); 
    112  
    113         iter = tny_list_create_iterator (priv->observers); 
     117        list = tny_list_copy (priv->observers); 
     118        g_static_rec_mutex_unlock (priv->obs_lock); 
     119 
     120        iter = tny_list_create_iterator (list); 
     121 
    114122        while (!tny_iterator_is_done (iter)) 
    115123        { 
     
    121129        g_object_unref (G_OBJECT (iter)); 
    122130 
    123         g_static_rec_mutex_unlock (priv->obs_lock); 
     131        g_object_unref (list); 
    124132 
    125133} 
  • trunk/libtinymailui-gtk/tny-gtk-header-list-model.c

    r1910 r1913  
    9494        g_return_val_if_fail (gtk_tree_path_get_depth (path) > 0, FALSE); 
    9595 
    96         g_static_rec_mutex_lock (list_model->iterator_lock); 
     96        g_static_rec_mutex_lock (list_model->iterator_lock);  
    9797 
    9898        i = gtk_tree_path_get_indices (path)[0]; 
     
    239239        gint i; 
    240240 
    241         if (iter->stamp != TNY_GTK_HEADER_LIST_MODEL (self)->stamp) 
     241        if (iter->stamp != list_model->stamp) 
    242242                return; 
    243243 
     
    572572        TnyGtkHeaderListModel *self; 
    573573        GObject *item; 
     574        GMainLoop *loop; 
    574575} notify_views_data_t; 
    575576 
     
    579580{ 
    580581        notify_views_data_t *stuff = data; 
     582 
    581583        g_object_unref (stuff->item); 
    582584        g_object_unref (stuff->self); 
     585 
     586        g_main_loop_unref (stuff->loop); 
     587 
    583588        g_slice_free (notify_views_data_t, data); 
    584589        return; 
     
    590595{ 
    591596        notify_views_data_t *stuff = data; 
    592         GObject *item = stuff->item; 
    593597        TnyGtkHeaderListModel *me = (TnyGtkHeaderListModel*) stuff->self; 
    594598        GtkTreePath *path; 
    595599        GtkTreeIter iter; 
    596         gint i; 
    597         gboolean found = FALSE; 
     600        gint i; gboolean found = FALSE; 
     601        GObject *mitem, *item = stuff->item; 
     602 
     603        g_static_rec_mutex_lock (me->iterator_lock); 
    598604 
    599605        for (i=0; i < me->items->len; i++) 
     
    610616                path = gtk_tree_path_new (); 
    611617                gtk_tree_path_append_index (path, i); 
    612                 if (G_LIKELY (path)) 
    613                 { 
    614                        gtk_tree_model_row_deleted (GTK_TREE_MODEL (me), path)
    615                        g_mutex_lock (me->ra_lock)
    616                        me->cur_len--
    617                        me->registered--
    618                         g_mutex_unlock (me->ra_lock); 
    619                        gtk_tree_path_free (path); 
    620                 } 
    621  
    622                g_static_rec_mutex_lock (me->iterator_lock); 
    623                 item = g_ptr_array_remove_index (me->items, i); 
    624                g_static_rec_mutex_unlock (me->iterator_lock); 
    625                 if (G_LIKELY (item))  
    626                        g_object_unref (item); 
    627         } 
     618                gtk_tree_model_row_deleted (GTK_TREE_MODEL (me), path); 
     619                g_mutex_lock (me->ra_lock); 
     620                me->cur_len--
     621                me->registered--
     622                g_mutex_unlock (me->ra_lock)
     623                gtk_tree_path_free (path)
     624 
     625                mitem = g_ptr_array_remove_index (me->items, i); 
     626                if (mitem) 
     627                        g_object_unref (mitem); 
     628        } 
     629 
     630        g_static_rec_mutex_unlock (me->iterator_lock); 
     631 
     632        if (g_main_loop_is_running (stuff->loop)) 
     633               g_main_loop_quit (stuff->loop); 
    628634 
    629635        return FALSE; 
    630636} 
    631637 
     638 
    632639static void 
    633640tny_gtk_header_list_model_remove (TnyList *self, GObject* item) 
    634641{ 
     642        TnyGtkHeaderListModel *me = (TnyGtkHeaderListModel*) self; 
    635643        notify_views_data_t *stuff; 
     644 
    636645        stuff = g_slice_new (notify_views_data_t); 
    637         stuff->self = g_object_ref (G_OBJECT (self)); 
     646        stuff->self = g_object_ref (self); 
    638647        stuff->item = g_object_ref (item); 
    639         g_timeout_add_full (0, G_PRIORITY_DEFAULT_IDLE,  
     648 
     649        stuff->loop = g_main_loop_new (NULL, FALSE); 
     650 
     651        g_timeout_add_full (0, G_PRIORITY_HIGH_IDLE,  
    640652                notify_views_delete, stuff, notify_views_delete_destroy); 
     653 
     654        /* This truly sucks :-( */ 
     655        g_main_loop_run (stuff->loop); 
     656 
    641657        return; 
    642658}