summaryrefslogtreecommitdiffstats
path: root/gio/ginputstream.override
diff options
context:
space:
mode:
authorPaul Pogonyshev <pogonyshev@gmx.net>2009-01-14 18:39:45 +0000
committerPaul Pogonyshev <paulp@src.gnome.org>2009-01-14 18:39:45 +0000
commit971c49ae3eec639d9472b3b2ee03713da1ef041c (patch)
tree2ee6880f229dfaa2e9538d283ae82954c0eb3a66 /gio/ginputstream.override
parentb5cf45145e8f0f62511aa072c0768612426455f1 (diff)
downloadpygobject-971c49ae3eec639d9472b3b2ee03713da1ef041c.tar.gz
pygobject-971c49ae3eec639d9472b3b2ee03713da1ef041c.tar.xz
pygobject-971c49ae3eec639d9472b3b2ee03713da1ef041c.zip
Bug 566706 – cleanup GIO overrides
2009-01-14 Paul Pogonyshev <pogonyshev@gmx.net> Bug 566706 – cleanup GIO overrides * gio/gio.override (pygio_notify_new) (pygio_notify_using_optional_callback) (pygio_notify_callback_is_valid_full) (pygio_notify_callback_is_valid) (pygio_notify_reference_callback): New functions. (pygio_notify_free): Rename from pygio_free_notify() and extend. (async_result_callback_marshal): Warn if new `referenced' field is not set (programming error). (_wrap_g_drive_eject, _wrap_g_drive_poll_for_media) (_wrap_g_mount_unmount, _wrap_g_mount_eject) (_wrap_g_mount_remount): Lots of cleanup: use new functions instead of repeating code, unify and fix error handling. * gio/gfile.override (_wrap_g_file_read_async) (_wrap_g_file_load_contents_async) (_wrap_g_file_enumerate_children_async) (_wrap_g_file_mount_mountable, _wrap_g_file_unmount_mountable) (_wrap_g_file_mount_enclosing_volume, _wrap_g_file_copy) (_wrap_g_file_copy_async, _wrap_g_file_move) (_wrap_g_file_append_to_async, _wrap_g_file_create_async) (_wrap_g_file_replace_async, _wrap_g_file_query_info_async) (_wrap_g_file_replace_contents_async): Similar cleanup. * gio/gfileenumerator.override (_wrap_g_file_enumerator_next_files_async): Similar cleanup. * gio/gicon.override (_wrap_g_loadable_icon_load_async): Similar cleanup. * gio/ginputstream.override (_wrap_g_input_stream_close_async): Similar cleanup. * gio/goutputstream.override (_wrap_g_output_stream_write_async) (_wrap_g_output_stream_close_async): Similar cleanup. * gio/gvolume.override (_wrap_g_volume_mount) (_wrap_g_volume_eject): Similar cleanup. * tests/test_gio.py (TestFile.test_copy_async): Fix the test. svn path=/trunk/; revision=996
Diffstat (limited to 'gio/ginputstream.override')
-rw-r--r--gio/ginputstream.override25
1 files changed, 11 insertions, 14 deletions
diff --git a/gio/ginputstream.override b/gio/ginputstream.override
index 443d974..43cd22f 100644
--- a/gio/ginputstream.override
+++ b/gio/ginputstream.override
@@ -318,7 +318,7 @@ _wrap_g_input_stream_close_async(PyGObject *self,
GCancellable *cancellable;
PyGIONotify *notify;
- notify = g_slice_new0(PyGIONotify);
+ notify = pygio_notify_new();
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"O|iOO:InputStream.close_async",
@@ -327,22 +327,15 @@ _wrap_g_input_stream_close_async(PyGObject *self,
&io_priority,
&pycancellable,
&notify->data))
- {
- g_slice_free(PyGIONotify, notify);
- return NULL;
- }
+ goto error;
- if (!PyCallable_Check(notify->callback))
- {
- PyErr_SetString(PyExc_TypeError, "callback argument not callable");
- g_slice_free(PyGIONotify, notify);
- return NULL;
- }
- Py_INCREF(notify->callback);
- Py_XINCREF(notify->data);
+ if (!pygio_notify_callback_is_valid(notify))
+ goto error;
if (!pygio_check_cancellable(pycancellable, &cancellable))
- return NULL;
+ goto error;
+
+ pygio_notify_reference_callback(notify);
g_input_stream_close_async(G_INPUT_STREAM(self->obj),
io_priority,
@@ -352,6 +345,10 @@ _wrap_g_input_stream_close_async(PyGObject *self,
Py_INCREF(Py_None);
return Py_None;
+
+ error:
+ pygio_notify_free(notify);
+ return NULL;
}
%%
override g_data_input_stream_read_line kwargs