Changeset 921

Show
Ignore:
Timestamp:
09/11/06 13:48:31
Author:
pvanhoof
Message:

API fixes, reference counting troubles

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/TODO

    r920 r921  
    33o. The docs don't describe the enums 
    44o. The docs don't describe the TnyGetFoldersCallback 
    5 o. The prerequisites of some types add GObject (this isn't needed) 
    6 o. The Python bindings don't wrap the TnyGetFoldersCallback 
    7 o. I think the tny_list_copy implementations need to add a reference to the items! 
     5o. The prerequisites of some types add GObject (this often isn't needed) 
     6o. Implement removing folders and messages (TnyFolderStore) 
     7o. Implement and design moving messages (TnyFolderStore?) 
  • trunk/bindings/python/tinymail.override

    r906 r921  
    3535import gobject.GObject as PyGObject_Type 
    3636%% 
     37override tny_folder_store_get_folders_async kwargs 
     38 
     39static void 
     40tny_get_folders_cb (TnyFolderStore *self, TnyList *list, gpointer user_data) 
     41{ 
     42    PyObject *callback, *args, *ret; 
     43    PyGILState_STATE state; 
     44 
     45    state = pyg_gil_state_ensure(); 
     46    callback = PyTuple_GetItem((PyObject *)user_data, 0); 
     47    args = Py_BuildValue("(NNO)", 
     48                         pygobject_new((GObject *)self), 
     49                         pygobject_new((GObject *)list), 
     50                         PyTuple_GetItem((PyObject *)user_data, 1)); 
     51    ret = PyObject_CallObject(callback, args); 
     52    if (!ret) 
     53        PyErr_Print(); 
     54    Py_XDECREF(ret); 
     55    Py_DECREF(args); 
     56    Py_DECREF ((PyObject *)user_data); 
     57    pyg_gil_state_release(state); 
     58} 
     59 
     60 
     61static PyObject * 
     62_wrap_tny_folder_store_get_folders_async (PyGObject *self, PyObject *args, PyObject *kwargs) 
     63{ 
     64    static char *kwlist[] = { "list", "get_folders_func", "query", "user_data", NULL }; 
     65    PyObject *get_folders_func = Py_None, *user_data = Py_None; 
     66    PyGObject *list = NULL, *query = NULL; 
     67    PyObject *data; 
     68 
     69    if (!PyArg_ParseTupleAndKeywords(args, kwargs, 
     70                                     "OO|OO:TnyFolderStore.get_folders_async", kwlist, 
     71                                     &list, &get_folders_func, &query, &user_data)) 
     72        return NULL; 
     73 
     74    if (!PyCallable_Check(get_folders_func)) { 
     75        PyErr_SetString(PyExc_TypeError, "get_folders_async must be callable"); 
     76        return NULL; 
     77    } 
     78   
     79    data = Py_BuildValue("(OO)", get_folders_func, user_data); 
     80 
     81    tny_folder_store_get_folders_async (TNY_FOLDER_STORE (self->obj), 
     82                                        TNY_LIST (list->obj), 
     83                                        tny_get_folders_cb,  
     84                                        query!=NULL?TNY_FOLDER_STORE_QUERY (query->obj):NULL,  
     85                                        data); 
     86    return Py_None; 
     87} 
     88%% 
    3789override tny_folder_refresh_async kwargs 
    3890 
     
    134186        /* TODO: check for failure? */ 
    135187                 
    136                tny_iterator_nth (iter, index); 
     188        tny_iterator_nth (iter, index); 
    137189        ret = tny_iterator_get_current (iter); 
    138         g_object_unref (G_OBJECT (ret)); 
     190 
     191        g_object_unref (G_OBJECT (ret)); /* IM Not sure about this one */ 
    139192        g_object_unref (G_OBJECT (iter)); 
    140193         
  • trunk/libtinymail/tny-list.c

    r908 r921  
    211211 * 
    212212 * Creates a copy of the list. It doesn't copy the items. It, however, creates 
    213  * a new list with new references to the same items. 
    214  * 
    215  * Because it's a new instance, the returned list object should be unreferenced 
    216  * after use. 
     213 * a new list with new references to the same items. The items will get an extra 
     214 * reference added for the new list being their second parent, setting their 
     215 * reference count to for example two. Which means that both lists (the original 
     216 * and the copy) must be unreferenced after use. 
    217217 * 
    218218 * Return value: A copy of this list 
  • trunk/libtinymail/tny-simple-list.c

    r900 r921  
    105105        g_mutex_lock (priv->iterator_lock); 
    106106        GList *list_copy = g_list_copy (priv->first); 
     107        g_list_foreach (list_copy, (GFunc)g_object_ref, NULL); 
    107108        cpriv->first = list_copy; 
    108109        g_mutex_unlock (priv->iterator_lock); 
  • trunk/libtinymailui-gtk/tny-gtk-account-tree-model.c

    r906 r921  
    274274        g_mutex_lock (me->iterator_lock); 
    275275        GList *list_copy = g_list_copy (me->first); 
     276        g_list_foreach (list_copy, (GFunc)g_object_ref, NULL); 
    276277        copy->first = list_copy; 
    277278        g_mutex_unlock (me->iterator_lock); 
  • trunk/libtinymailui-gtk/tny-gtk-attach-list-model.c

    r900 r921  
    301301        g_mutex_lock (me->iterator_lock); 
    302302        GList *list_copy = g_list_copy (me->first); 
     303        g_list_foreach (list_copy, (GFunc)g_object_ref, NULL); 
    303304        copy->first = list_copy; 
    304305        g_mutex_unlock (me->iterator_lock); 
  • trunk/libtinymailui-gtk/tny-gtk-header-list-model.c

    r906 r921  
    708708        g_mutex_lock (me->iterator_lock); 
    709709        GList *list_copy = g_list_copy (me->first); 
     710        g_list_foreach (list_copy, (GFunc)g_object_ref, NULL); 
    710711        copy->first = list_copy; 
    711712        copy->usable_index = FALSE;