pygobject r1016 - in branches/pygobject-2-16: . gio gobject



Author: gianmt
Date: Fri Feb 20 22:02:04 2009
New Revision: 1016
URL: http://svn.gnome.org/viewvc/pygobject?rev=1016&view=rev

Log:
2009-02-08  Gian Mario Tagliaretti  <gianmt gnome org>

	Bug 568427 â "gio.Error: Too many open files" without too many
	open files
	
	* gobject/pygtype.c (_wrap_g_type_wrapper__get_name):
	* gobject/gobjectmodule.c (get_type_name_for_class):
	* gobject/pygobject.c (build_parameter_list), (PyGProps_length):
	* gio/gfileinfo.override (_wrap_g_file_info_list_attributes):
	* gio/gio.override (_wrap_g_content_type_guess):
	* gio/gfile.override (_wrap__file_init), 
(_wrap_g_file_load_contents)
	(_wrap_g_file_load_contents_finish): Remove some memory leaks.
	
	* gio/gio.defs: add (caller-owns-return #t) all over the place 
to
	prevent memory leaks.
	
	patch contributed by Paul Pogonyshev, Paolo Borelli and
	Gian Mario Tagliaretti.



Modified:
   branches/pygobject-2-16/ChangeLog
   branches/pygobject-2-16/gio/gfile.override
   branches/pygobject-2-16/gio/gfileinfo.override
   branches/pygobject-2-16/gio/gio.defs
   branches/pygobject-2-16/gio/gio.override
   branches/pygobject-2-16/gobject/gobjectmodule.c
   branches/pygobject-2-16/gobject/pygobject.c
   branches/pygobject-2-16/gobject/pygtype.c

Modified: branches/pygobject-2-16/gio/gfile.override
==============================================================================
--- branches/pygobject-2-16/gio/gfile.override	(original)
+++ branches/pygobject-2-16/gio/gfile.override	Fri Feb 20 22:02:04 2009
@@ -75,6 +75,7 @@
     GFile *file;
     Py_ssize_t n_args, n_kwargs;
     char *arg;
+    PyObject *py_ret;
 
     n_args = PyTuple_Size(args);
     n_kwargs = kwargs != NULL ? PyDict_Size(kwargs) : 0;
@@ -114,7 +115,11 @@
 			"could not create GFile object");
         return NULL;
     }
-    return pygobject_new((GObject *)file);
+
+    py_ret = pygobject_new((GObject *)file);
+    g_object_unref(file);
+
+    return py_ret;
 }
 %%
 override g_file_read_async kwargs
@@ -192,9 +197,14 @@
     if (pyg_error_check(&error))
         return NULL;
 
-    if (ret)
-        return Py_BuildValue("(s#ks)", contents, length, length, etag_out);
-    else {
+    if (ret) {
+        PyObject *pyret;
+
+        pyret = Py_BuildValue("(s#ks)", contents, length, length, etag_out);
+        g_free(contents);
+	g_free(etag_out);
+        return pyret;
+    } else {
         Py_INCREF(Py_None);
         return Py_None;
     }
@@ -269,9 +279,14 @@
     if (pyg_error_check(&error))
         return NULL;
 
-    if (ret)
-        return Py_BuildValue("(s#ks)", contents, length, length, etag_out);
-    else {
+    if (ret) {
+        PyObject *pyret;
+
+        pyret = Py_BuildValue("(s#ks)", contents, length, length, etag_out);
+        g_free(contents);
+	g_free(etag_out);
+        return pyret;
+    } else {
         Py_INCREF(Py_None);
         return Py_None;
     }

Modified: branches/pygobject-2-16/gio/gfileinfo.override
==============================================================================
--- branches/pygobject-2-16/gio/gfileinfo.override	(original)
+++ branches/pygobject-2-16/gio/gfileinfo.override	Fri Feb 20 22:02:04 2009
@@ -29,6 +29,7 @@
     char *kwlist[] = { "name_space", NULL};
     gchar *name_space;
     gchar **names;
+    gchar **n;
     PyObject *ret;
     
     if (!PyArg_ParseTupleAndKeywords(args, kwargs,
@@ -40,14 +41,16 @@
 					name_space);
 
     ret = PyList_New(0);
-    while (names && *names) {
-        PyObject *item = PyString_FromString(names[0]);
+    n = names;
+    while (n && *n) {
+        PyObject *item = PyString_FromString(n[0]);
         PyList_Append(ret, item);
         Py_DECREF(item);
 
-        names++;
+        n++;
     }
-
+    
+    g_strfreev(names);
     return ret;
 }
 %%

Modified: branches/pygobject-2-16/gio/gio.defs
==============================================================================
--- branches/pygobject-2-16/gio/gio.defs	(original)
+++ branches/pygobject-2-16/gio/gio.defs	Fri Feb 20 22:02:04 2009
@@ -28,6 +28,7 @@
   (of-object "GAppInfo")
   (c-name "g_app_info_dup")
   (return-type "GAppInfo*")
+  (caller-owns-return #t)
 )
 
 (define-method equal
@@ -69,6 +70,9 @@
   (return-type "GIcon*")
 )
 
+;;
+;; wrapped in gappinfo.override
+;;
 (define-method launch
   (docstring
   "launch (files=None, launch_context=None) -> gboolean\n"
@@ -107,6 +111,9 @@
   (return-type "gboolean")
 )
 
+;;
+;; wrapped in gappinfo.override
+;;
 (define-method launch_uris
   (docstring
   "launch_uris (files=None, launch_context=None) -> gboolean\n"
@@ -183,11 +190,17 @@
   )
 )
 
+;;
+;; wrapped in gio.override
+;;
 (define-function app_info_get_all
   (c-name "g_app_info_get_all")
   (return-type "GList*")
 )
 
+;;
+;; wrapped in gio.override
+;;
 (define-function app_info_get_all_for_type
   (c-name "g_app_info_get_all_for_type")
   (return-type "GList*")
@@ -219,6 +232,9 @@
   (return-type "GAppLaunchContext*")
 )
 
+;;
+;; wrapped in gapplaunchcontext.override
+;;
 (define-method get_display
   (of-object "GAppLaunchContext")
   (c-name "g_app_launch_context_get_display")
@@ -229,6 +245,9 @@
   )
 )
 
+;;
+;; wrapped in gapplaunchcontext.override
+;;
 (define-method get_startup_notify_id
   (of-object "GAppLaunchContext")
   (c-name "g_app_launch_context_get_startup_notify_id")
@@ -556,6 +575,7 @@
 (define-function content_type_get_icon
   (c-name "g_content_type_get_icon")
   (return-type "GIcon*")
+  (caller-owns-return #t)
   (parameters
     '("const-char*" "type")
   )
@@ -569,6 +589,9 @@
   )
 )
 
+;;
+;; wrapped in gio.override
+;;
 (define-function content_type_guess
   (docstring
 "content_type_guess([filename, data, want_uncertain]) -> mime type\n"
@@ -588,6 +611,9 @@
   )
 )
 
+;;
+;; wrapped in gio.override
+;;
 (define-function content_types_get_registered
   (c-name "g_content_types_get_registered")
   (return-type "GList*")
@@ -711,6 +737,9 @@
   )
 )
 
+;;
+;; wrapped in ginputstream.override
+;;
 (define-method read_line
   (of-object "GDataInputStream")
   (docstring
@@ -726,6 +755,9 @@
   )
 )
 
+;;
+;; wrapped in ginputstream.override
+;;
 (define-method read_until
   (of-object "GDataInputStream")
   (docstring
@@ -886,6 +918,7 @@
   (of-object "GDrive")
   (c-name "g_drive_get_icon")
   (return-type "GIcon*")
+  (caller-owns-return #t)
 )
 
 (define-method has_volumes
@@ -894,6 +927,9 @@
   (return-type "gboolean")
 )
 
+;;
+;; wrapped in gio.override
+;;
 (define-method get_volumes
   (of-object "GDrive")
   (c-name "g_drive_get_volumes")
@@ -930,6 +966,9 @@
   (return-type "gboolean")
 )
 
+;;
+;; wrapped in gio.override
+;;
 (define-method eject
   (of-object "GDrive")
   (docstring
@@ -957,6 +996,9 @@
   )
 )
 
+;;
+;; wrapped in gio.override
+;;
 (define-method poll_for_media
   (of-object "GDrive")
   (docstring
@@ -1049,6 +1091,7 @@
   (of-object "GFileEnumerator")
   (c-name "g_file_enumerator_next_file")
   (return-type "GFileInfo*")
+  (caller-owns-return #t)
   (parameters
     '("GCancellable*" "cancellable" (null-ok) (default "NULL"))
     '("GError**" "error")
@@ -1065,6 +1108,9 @@
   )
 )
 
+;;
+;; wrapped in gfileenumerator.override
+;;
 (define-method next_files_async
   (docstring
 "FE.next_files_async(num_files, callback, [io_priority, cancellable,\n"
@@ -1098,6 +1144,9 @@
   )
 )
 
+;;
+;; wrapped in gfileenumerator.override
+;;
 (define-method next_files_finish
   (docstring
 "FE.next_files_finish(result) -> a list of gio.FileInfos\n"
@@ -1194,6 +1243,7 @@
 (define-function file_parse_name
   (c-name "g_file_parse_name")
   (return-type "GFile*")
+  (caller-owns-return #t)
   (parameters
     '("const-char*" "parse_name")
   )
@@ -1203,6 +1253,7 @@
   (of-object "GFile")
   (c-name "g_file_dup")
   (return-type "GFile*")
+  (caller-owns-return #t)
 )
 
 (define-function file_hash
@@ -1250,12 +1301,14 @@
   (of-object "GFile")
   (c-name "g_file_get_parent")
   (return-type "GFile*")
+  (caller-owns-return #t)
 )
 
 (define-method get_child
   (of-object "GFile")
   (c-name "g_file_get_child")
   (return-type "GFile*")
+  (caller-owns-return #t)
   (parameters
     '("const-char*" "name")
   )
@@ -1265,6 +1318,7 @@
   (of-object "GFile")
   (c-name "g_file_get_child_for_display_name")
   (return-type "GFile*")
+  (caller-owns-return #t)
   (parameters
     '("const-char*" "display_name")
     '("GError**" "error")
@@ -1293,6 +1347,7 @@
   (of-object "GFile")
   (c-name "g_file_resolve_relative_path")
   (return-type "GFile*")
+  (caller-owns-return #t)
   (parameters
     '("const-char*" "relative_path")
   )
@@ -1336,12 +1391,16 @@
   )
   (c-name "g_file_read")
   (return-type "GFileInputStream*")
+  (caller-owns-return #t)
   (parameters
     '("GCancellable*" "cancellable" (null-ok) (default "NULL"))
     '("GError**" "error")
   )
 )
 
+;;
+;; wrapped in gfile.override
+;;
 (define-method read_async
   (of-object "GFile")
   (docstring
@@ -1368,6 +1427,7 @@
   (of-object "GFile")
   (c-name "g_file_read_finish")
   (return-type "GFileInputStream*")
+  (caller-owns-return #t)
   (parameters
     '("GAsyncResult*" "res")
     '("GError**" "error")
@@ -1378,6 +1438,7 @@
   (of-object "GFile")
   (c-name "g_file_append_to")
   (return-type "GFileOutputStream*")
+  (caller-owns-return #t)
   (parameters
     '("GFileCreateFlags" "flags" (default "G_FILE_CREATE_NONE"))
     '("GCancellable*" "cancellable" (null-ok) (default "NULL"))
@@ -1389,6 +1450,7 @@
   (of-object "GFile")
   (c-name "g_file_create")
   (return-type "GFileOutputStream*")
+  (caller-owns-return #t)
   (parameters
     '("GFileCreateFlags" "flags" (default "G_FILE_CREATE_NONE"))
     '("GCancellable*" "cancellable" (null-ok) (default "NULL"))
@@ -1400,6 +1462,7 @@
   (of-object "GFile")
   (c-name "g_file_replace")
   (return-type "GFileOutputStream*")
+  (caller-owns-return #t)
   (parameters
     '("const-char*" "etag")
     '("gboolean" "make_backup")
@@ -1409,6 +1472,9 @@
   )
 )
 
+;;
+;; wrapped in gfile.override
+;;
 (define-method append_to_async
   (docstring
   "F.append_to_async(callback [flags, [,io_priority [,cancellable\n"
@@ -1436,12 +1502,16 @@
   (of-object "GFile")
   (c-name "g_file_append_to_finish")
   (return-type "GFileOutputStream*")
+  (caller-owns-return #t)
   (parameters
     '("GAsyncResult*" "res")
     '("GError**" "error")
   )
 )
 
+;;
+;; wrapped in gfile.override
+;;
 (define-method create_async
   (docstring
   "F.create_async(callback [flags, [,io_priority [,cancellable\n"
@@ -1470,12 +1540,16 @@
   (of-object "GFile")
   (c-name "g_file_create_finish")
   (return-type "GFileOutputStream*")
+  (caller-owns-return #t)
   (parameters
     '("GAsyncResult*" "res")
     '("GError**" "error")
   )
 )
 
+;;
+;; wrapped in gfile.override
+;;
 (define-method replace_async
   (docstring
   "F.replace_async(callback [etag, [make_backup, [flags, [io_priority,\n"
@@ -1506,6 +1580,7 @@
   (of-object "GFile")
   (c-name "g_file_replace_finish")
   (return-type "GFileOutputStream*")
+  (caller-owns-return #t)
   (parameters
     '("GAsyncResult*" "res")
     '("GError**" "error")
@@ -1525,6 +1600,7 @@
   (of-object "GFile")
   (c-name "g_file_query_info")
   (return-type "GFileInfo*")
+  (caller-owns-return #t)
   (parameters
     '("const-char*" "attributes")
     '("GFileQueryInfoFlags" "flags" (default "G_FILE_QUERY_INFO_NONE"))
@@ -1533,6 +1609,9 @@
   )
 )
 
+;;
+;; wrapped in gfile.override
+;;
 (define-method query_info_async
   (docstring
   "F.query_info_async(callback, attributes, [flags, [io_priority,\n"
@@ -1563,6 +1642,7 @@
   (of-object "GFile")
   (c-name "g_file_query_info_finish")
   (return-type "GFileInfo*")
+  (caller-owns-return #t)
   (parameters
     '("GAsyncResult*" "res")
     '("GError**" "error")
@@ -1573,6 +1653,7 @@
   (of-object "GFile")
   (c-name "g_file_query_filesystem_info")
   (return-type "GFileInfo*")
+  (caller-owns-return #t)
   (parameters
     '("const-char*" "attributes")
     '("GCancellable*" "cancellable" (null-ok) (default "NULL"))
@@ -1584,6 +1665,7 @@
   (of-object "GFile")
   (c-name "g_file_find_enclosing_mount")
   (return-type "GMount*")
+  (caller-owns-return #t)
   (parameters
     '("GCancellable*" "cancellable" (null-ok) (default "NULL"))
     '("GError**" "error")
@@ -1606,6 +1688,7 @@
   (of-object "GFile")
   (c-name "g_file_find_enclosing_mount_finish")
   (return-type "GMount*")
+  (caller-owns-return #t)
   (parameters
     '("GAsyncResult*" "res")
     '("GError**" "error")
@@ -1637,6 +1720,7 @@
   (of-object "GFile")
   (c-name "g_file_enumerate_children")
   (return-type "GFileEnumerator*")
+  (caller-owns-return #t)
   (parameters
     '("const-char*" "attributes")
     '("GFileQueryInfoFlags" "flags" (default "G_FILE_QUERY_INFO_NONE"))
@@ -1645,6 +1729,9 @@
   )
 )
 
+;;
+;; wrapped in gfile.override
+;;
 (define-method enumerate_children_async
   (docstring
 "F.enumerate_children_async(attributes, callback,\n"
@@ -1675,6 +1762,7 @@
   (of-object "GFile")
   (c-name "g_file_enumerate_children_finish")
   (return-type "GFileEnumerator*")
+  (caller-owns-return #t)
   (parameters
     '("GAsyncResult*" "res")
     '("GError**" "error")
@@ -1685,6 +1773,7 @@
   (of-object "GFile")
   (c-name "g_file_set_display_name")
   (return-type "GFile*")
+  (caller-owns-return #t)
   (parameters
     '("const-char*" "display_name")
     '("GCancellable*" "cancellable" (null-ok) (default "NULL"))
@@ -1709,6 +1798,7 @@
   (of-object "GFile")
   (c-name "g_file_set_display_name_finish")
   (return-type "GFile*")
+  (caller-owns-return #t)
   (parameters
     '("GAsyncResult*" "res")
     '("GError**" "error")
@@ -1735,6 +1825,9 @@
   )
 )
 
+;;
+;; wrapped in gfile.override
+;;
 (define-method copy
   (docstring
 "F.copy(destination, [callback, flags, cancellable, user_data])\n"
@@ -1788,6 +1881,10 @@
   )
 )
 
+
+;;
+;; wrapped in gfile.override
+;;
 (define-method move
   (docstring
 "F.move(destination, [callback, flags, cancellable, user_data])\n"
@@ -1863,6 +1960,9 @@
   )
 )
 
+;;
+;; wrapped in gfile.override
+;;
 (define-method query_settable_attributes
   (docstring
   "F.query_settable_attributes([cancellable]) -> list\n\n"
@@ -1884,6 +1984,9 @@
   )
 )
 
+;;
+;; wrapped in gfile.override
+;;
 (define-method query_writable_namespaces
   (docstring
   "F.query_writable_namespaces([cancellable]) -> list\n\n"
@@ -1904,6 +2007,9 @@
   )
 )
 
+;;
+;; wrapped in gfile.override
+;;
 (define-method set_attribute
   (docstring
   "F.set_attribute(attribute, type, value_p [,flags [,cancellable ]])->bool\n"
@@ -2041,6 +2147,9 @@
   )
 )
 
+;;
+;; wrapped in gfile.override
+;;
 (define-method mount_enclosing_volume
   (docstring
 "F.mount_enclosing_volume(mount_operation, callback, [cancellable,\n"
@@ -2077,6 +2186,9 @@
   )
 )
 
+;;
+;; wrapped in gfile.override
+;;
 (define-method mount_mountable
   (docstring
 "F.mount_mountable(mount_operation, callback, [flags, cancellable,\n"
@@ -2106,12 +2218,16 @@
   (of-object "GFile")
   (c-name "g_file_mount_mountable_finish")
   (return-type "GFile*")
+  (caller-owns-return #t)
   (parameters
     '("GAsyncResult*" "result")
     '("GError**" "error")
   )
 )
 
+;;
+;; wrapped in gfile.override
+;;
 (define-method unmount_mountable
   (docstring
 "F.unmount_mountable(callback, [flags, cancellable, user_data])\n"
@@ -2167,6 +2283,7 @@
   )
 )
 
+
 (define-method copy_attributes
   (of-object "GFile")
   (c-name "g_file_copy_attributes")
@@ -2183,6 +2300,7 @@
   (of-object "GFile")
   (c-name "g_file_monitor_directory")
   (return-type "GFileMonitor*")
+  (caller-owns-return #t)
   (parameters
     '("GFileMonitorFlags" "flags" (default "G_FILE_MONITOR_NONE"))
     '("GCancellable*" "cancellable" (null-ok) (default "NULL"))
@@ -2194,6 +2312,7 @@
   (of-object "GFile")
   (c-name "g_file_monitor_file")
   (return-type "GFileMonitor*")
+  (caller-owns-return #t)
   (parameters
     '("GFileMonitorFlags" "flags" (default "G_FILE_MONITOR_NONE"))
     '("GCancellable*" "cancellable" (null-ok) (default "NULL"))
@@ -2205,12 +2324,16 @@
   (of-object "GFile")
   (c-name "g_file_query_default_handler")
   (return-type "GAppInfo*")
+  (caller-owns-return #t)
   (parameters
     '("GCancellable*" "cancellable" (null-ok) (default "NULL"))
     '("GError**" "error")
   )
 )
 
+;;
+;; wrapped in gfile.override
+;;
 (define-method load_contents
   (docstring
   "F.load_contents([cancellable]) -> contents, length, etag_out\n\n"
@@ -2233,6 +2356,9 @@
   )
 )
 
+;;
+;; wrapped in gfile.override
+;;
 (define-method load_contents_async
   (docstring
   "F.load_contents_async(callback, [cancellable, [user_data]])->start loading\n\n"
@@ -2256,6 +2382,9 @@
   )
 )
 
+;;
+;; wrapped in gfile.override
+;;
 (define-method load_contents_finish
   (docstring
   "F.load_contents_finish(res) -> contents, length, etag_out\n\n"
@@ -2301,6 +2430,9 @@
   )
 )
 
+;;
+;; wrapped in gfile.override
+;;
 (define-method replace_contents
   (docstring
   "F.replace_contents(contents, [etag, [make_backup, [flags, [cancellable]]]])\n"
@@ -2329,6 +2461,9 @@
   )
 )
 
+;;
+;; wrapped in gfile.override
+;;
 (define-method replace_contents_async
   (docstring
   "F.replace_contents_async(contents, callback, [etag, [make_backup, [flags,\n"
@@ -2359,6 +2494,9 @@
   )
 )
 
+;;
+;; wrapped in gfile.override
+;;
 (define-method replace_contents_finish
   (docstring
   "F.replace_contents_finish(res) -> etag_out\n\n"
@@ -2421,6 +2559,7 @@
   (of-object "GFileInfo")
   (c-name "g_file_info_dup")
   (return-type "GFileInfo*")
+  (caller-owns-return #t)
 )
 
 (define-method copy_into
@@ -2441,6 +2580,8 @@
   )
 )
 
+;;
+;; wrapped in  gfileinfo.override
 (define-method list_attributes
   (docstring
   "INFO.list_attributes(name_space) -> Attribute list\n\n"
@@ -2731,6 +2872,9 @@
   (return-type "goffset")
 )
 
+;;
+;; wrapped in gfileinfo.override
+;;
 (define-method get_modification_time
   (docstring
 "INFO.get_modification_time() -> modification time\n"
@@ -3177,6 +3321,9 @@
   (return-type "GType")
 )
 
+;;
+;; wrapped in ginputstream.override
+;;
 ;; Note: the following two methods are renamed for consistency with
 ;; Python file objects' read().  I.e. g_input_stream_read_all() is
 ;; more like Python file.read(), so it is renamed read().  Since now
@@ -3207,6 +3354,9 @@
   )
 )
 
+;;
+;; wrapped in ginputstream.override
+;;
 ;; See comments before the previous method definition.
 (define-method read
   (of-object "GInputStream")
@@ -3254,6 +3404,9 @@
   )
 )
 
+;;
+;; wrapped in ginputstream.override
+;;
 (define-method read_async
   (of-object "GInputStream")
   (c-name "g_input_stream_read_async")
@@ -3268,6 +3421,9 @@
   )
 )
 
+;;
+;; wrapped in ginputstream.override
+;;
 (define-method read_finish
   (of-object "GInputStream")
   (c-name "g_input_stream_read_finish")
@@ -3301,6 +3457,9 @@
   )
 )
 
+;;
+;; wrapped in ginputstream.override
+;;
 (define-method close_async
   (of-object "GInputStream")
   (c-name "g_input_stream_close_async")
@@ -3553,6 +3712,9 @@
   (return-type "GType")
 )
 
+;;
+;; wrapped in gicon.override
+;;
 (define-method load
   (of-object "GLoadableIcon")
   (docstring
@@ -3579,6 +3741,9 @@
   )
 )
 
+;;
+;; wrapped in gicon.override
+;;
 (define-method load_async
   (of-object "GLoadableIcon")
   (docstring
@@ -3601,6 +3766,9 @@
   )
 )
 
+;;
+;; wrapped in gicon.override
+;;
 (define-method load_finish
   (docstring
   "F.load_finish(res) -> start loading\n"
@@ -3686,6 +3854,9 @@
   )
 )
 
+;;
+;; wrapped in ginputstream.override
+;;
 (define-method add_data
   (of-object "GMemoryInputStream")
   (c-name "g_memory_input_stream_add_data")
@@ -3706,6 +3877,9 @@
   (return-type "GType")
 )
 
+;;
+;; wrapped in goutputstream.override
+;;
 (define-function memory_output_stream_new
   (c-name "g_memory_output_stream_new")
   (is-constructor-of "GMemoryOutputStream")
@@ -3718,6 +3892,9 @@
   )
 )
 
+;;
+;; wrapped in goutputstream.override
+;;
 ;; Note: name clash with gobject.GObject.get_data; renamed.
 (define-method get_contents
   (of-object "GMemoryOutputStream")
@@ -3744,6 +3921,7 @@
   (of-object "GMount")
   (c-name "g_mount_get_root")
   (return-type "GFile*")
+  (caller-owns-return #t)
 )
 
 (define-method get_name
@@ -3756,6 +3934,7 @@
   (of-object "GMount")
   (c-name "g_mount_get_icon")
   (return-type "GIcon*")
+  (caller-owns-return #t)
 )
 
 (define-method get_uuid
@@ -3768,12 +3947,14 @@
   (of-object "GMount")
   (c-name "g_mount_get_volume")
   (return-type "GVolume*")
+  (caller-owns-return #t)
 )
 
 (define-method get_drive
   (of-object "GMount")
   (c-name "g_mount_get_drive")
   (return-type "GDrive*")
+  (caller-owns-return #t)
 )
 
 (define-method can_unmount
@@ -3788,6 +3969,9 @@
   (return-type "gboolean")
 )
 
+;;
+;; wrapped in gio.override
+;;
 (define-method unmount
   (docstring
 "M.unmount(callback, [flags, cancellable, user_data])\n"
@@ -3816,6 +4000,9 @@
   )
 )
 
+;;
+;; wrapped in gio.override
+;;
 (define-method eject
   (docstring
 "F.eject(callback, [flags, cancellable, user_data])\n"
@@ -3848,6 +4035,9 @@
   )
 )
 
+;;
+;; wrapped in gio.override
+;;
 (define-method remount
   (of-object "GMount")
   (docstring
@@ -4007,6 +4197,9 @@
   (return-type "GType")
 )
 
+;;
+;; wrapped in goutputstream.override
+;;
 ;; Note: the following two methods are renamed for consistency with
 ;; Python file objects' write().  I.e. g_output_stream_write_all() is
 ;; more like Python file.write(), so it is renamed write().  Since now
@@ -4035,6 +4228,9 @@
   )
 )
 
+;;
+;; wrapped in goutputstream.override
+;;
 ;; See comments before the previous method definition.
 (define-method write
   (of-object "GOutputStream")
@@ -4090,6 +4286,9 @@
   )
 )
 
+;;
+;; wrapped in goutputstream.override
+;;
 (define-method write_async
   (of-object "GOutputStream")
   (docstring
@@ -4172,6 +4371,9 @@
   )
 )
 
+;;
+;; wrapped in goutputstream.override
+;;
 (define-method close_async
   (of-object "GOutputStream")
   (c-name "g_output_stream_close_async")
@@ -4507,6 +4709,9 @@
   )
 )
 
+;;
+;; wrapped in gicon.override
+;;
 (define-method get_names
   (c-name "g_themed_icon_get_names")
   (of-object "GThemedIcon")
@@ -4563,6 +4768,7 @@
   (of-object "GVfs")
   (c-name "g_vfs_get_file_for_path")
   (return-type "GFile*")
+  (caller-owns-return #t)
   (parameters
     '("const-char*" "path")
   )
@@ -4572,6 +4778,7 @@
   (of-object "GVfs")
   (c-name "g_vfs_get_file_for_uri")
   (return-type "GFile*")
+  (caller-owns-return #t)
   (parameters
     '("const-char*" "uri")
   )
@@ -4581,6 +4788,7 @@
   (of-object "GVfs")
   (c-name "g_vfs_parse_name")
   (return-type "GFile*")
+  (caller-owns-return #t)
   (parameters
     '("const-char*" "parse_name")
   )
@@ -4596,6 +4804,9 @@
   (return-type "GVfs*")
 )
 
+;;
+;; wrapped in gio.override
+;;
 (define-method get_supported_uri_schemes
   (docstring
 "VFS.get_supported_uri_schemes() -> [uri, ..]\n"
@@ -4633,6 +4844,7 @@
   (of-object "GVolume")
   (c-name "g_volume_get_icon")
   (return-type "GIcon*")
+  (caller-owns-return #t)
 )
 
 (define-method get_uuid
@@ -4645,12 +4857,14 @@
   (of-object "GVolume")
   (c-name "g_volume_get_drive")
   (return-type "GDrive*")
+  (caller-owns-return #t)
 )
 
 (define-method get_mount
   (of-object "GVolume")
   (c-name "g_volume_get_mount")
   (return-type "GMount*")
+  (caller-owns-return #t)
 )
 
 (define-method can_mount
@@ -4665,6 +4879,9 @@
   (return-type "gboolean")
 )
 
+;;
+;; wrapped in gvolume.override
+;;
 (define-method mount
   (docstring
 "V.mount(mount_operation, callback, [flags, cancellable, user_data])\n"
@@ -4699,6 +4916,9 @@
   )
 )
 
+;;
+;; wrapped in gvolume.override
+;;
 (define-method eject
   (of-object "GVolume")
   (c-name "g_volume_eject")
@@ -4735,18 +4955,27 @@
   (return-type "GVolumeMonitor*")
 )
 
+;;
+;; wrapped in gvolumemonitor.override
+;;
 (define-method get_connected_drives
   (of-object "GVolumeMonitor")
   (c-name "g_volume_monitor_get_connected_drives")
   (return-type "GList*")
 )
 
+;;
+;; wrapped in gvolumemonitor.override
+;;
 (define-method get_volumes
   (of-object "GVolumeMonitor")
   (c-name "g_volume_monitor_get_volumes")
   (return-type "GList*")
 )
 
+;;
+;; wrapped in gvolumemonitor.override
+;;
 (define-method get_mounts
   (of-object "GVolumeMonitor")
   (c-name "g_volume_monitor_get_mounts")
@@ -4757,6 +4986,7 @@
   (of-object "GVolumeMonitor")
   (c-name "g_volume_monitor_get_volume_for_uuid")
   (return-type "GVolume*")
+  (caller-owns-return #t)
   (parameters
     '("const-char*" "uuid")
   )
@@ -4766,6 +4996,7 @@
   (of-object "GVolumeMonitor")
   (c-name "g_volume_monitor_get_mount_for_uuid")
   (return-type "GMount*")
+  (caller-owns-return #t)
   (parameters
     '("const-char*" "uuid")
   )

Modified: branches/pygobject-2-16/gio/gio.override
==============================================================================
--- branches/pygobject-2-16/gio/gio.override	(original)
+++ branches/pygobject-2-16/gio/gio.override	Fri Feb 20 22:02:04 2009
@@ -417,6 +417,7 @@
     char *filename = NULL, *data = NULL, *type;
     int data_size = 0;
     gboolean result_uncertain, want_uncertain = FALSE;
+    PyObject *ret;
 
     if (!PyArg_ParseTupleAndKeywords (args, kwargs,
 				      "|zz#i:g_content_type_guess",
@@ -433,10 +434,15 @@
     type = g_content_type_guess(filename, (guchar *) data,
 				data_size, &result_uncertain);
 
-    if (want_uncertain)
-	return Py_BuildValue("zN", type,
-			     PyBool_FromLong(result_uncertain));
-    return PyString_FromString(type);
+    if (want_uncertain) {
+	ret = Py_BuildValue("zN", type, PyBool_FromLong(result_uncertain));
+    
+    } else {
+        ret = PyString_FromString(type);
+    }
+
+    g_free(type);
+    return ret;
 }
 %%
 override g_mount_unmount kwargs

Modified: branches/pygobject-2-16/gobject/gobjectmodule.c
==============================================================================
--- branches/pygobject-2-16/gobject/gobjectmodule.c	(original)
+++ branches/pygobject-2-16/gobject/gobjectmodule.c	Fri Feb 20 22:02:04 2009
@@ -965,13 +965,14 @@
     gint i, name_serial;
     char name_serial_str[16];
     PyObject *module;
-    char *type_name;
+    char *type_name = NULL;
     
     /* make name for new GType */
     name_serial = 1;
     /* give up after 1000 tries, just in case.. */
     while (name_serial < 1000) 
     {
+	g_free(type_name);
 	snprintf(name_serial_str, 16, "-v%i", name_serial);
 	module = PyObject_GetAttrString((PyObject *)class, "__module__");
 	if (module && _PyUnicode_Check(module)) {

Modified: branches/pygobject-2-16/gobject/pygobject.c
==============================================================================
--- branches/pygobject-2-16/gobject/pygobject.c	(original)
+++ branches/pygobject-2-16/gobject/pygobject.c	Fri Feb 20 22:02:04 2009
@@ -231,18 +231,19 @@
     GParamSpec **props;
     guint n_props = 0, i;
     PyObject *prop_str;
-    char *name;
     PyObject *props_list;
 
     props = g_object_class_list_properties(class, &n_props);
     props_list = PyList_New(n_props);
     for (i = 0; i < n_props; i++) {
+	char *name;
 	name = g_strdup(g_param_spec_get_name(props[i]));
 	/* hyphens cannot belong in identifiers */
 	g_strdelimit(name, "-", '_');
 	prop_str = _PyUnicode_FromString(name);
 	
 	PyList_SetItem(props_list, i, prop_str);
+	g_free(name);
     }
 
     if (props)
@@ -400,12 +401,14 @@
 PyGProps_length(PyGProps *self)
 {
     GObjectClass *class;
+    GParamSpec **props;
     guint n_props;
     
     class = g_type_class_ref(self->gtype);
-    g_object_class_list_properties(class, &n_props);
+    props = g_object_class_list_properties(class, &n_props);
     g_type_class_unref(class);
-    
+    g_free(props);
+
     return (Py_ssize_t)n_props;
 }
 

Modified: branches/pygobject-2-16/gobject/pygtype.c
==============================================================================
--- branches/pygobject-2-16/gobject/pygtype.c	(original)
+++ branches/pygobject-2-16/gobject/pygtype.c	Fri Feb 20 22:02:04 2009
@@ -87,7 +87,7 @@
 _wrap_g_type_wrapper__get_name(PyGTypeWrapper *self, void *closure)
 {
    const char *name = g_type_name(self->type);
-   return _PyUnicode_FromString(g_strdup(name ? name : "invalid"));
+   return _PyUnicode_FromString(name ? name : "invalid");
 }
 
 static PyObject *
@@ -860,6 +860,7 @@
                 return -1;
             string = g_string_new_len(buffer, len);
 	    g_value_set_boxed(value, string);
+	    g_string_free (string, TRUE);
             break;
         }
 	else if ((bm = pyg_type_lookup(G_VALUE_TYPE(value))) != NULL)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]