pygobject r980 - in branches/pygobject-2-16: . gio



Author: paulp
Date: Sun Dec 21 15:42:39 2008
New Revision: 980
URL: http://svn.gnome.org/viewvc/pygobject?rev=980&view=rev

Log:
2008-12-21  Paul Pogonyshev  <pogonyshev gmx net>

	Bug 564102 â _wrap_g_output_stream_write_async not adding a
	reference to the buffer passed

	* gio/gio.override (pygio_notify_copy_buffer): New function.
	(pygio_free_notify): Free new `buffer' field if it is set.

	* gio/goutputstream.override (_wrap_g_output_stream_write_async):
	Copy the buffer with new pygio_notify_copy_buffer() and use the
	copy for g_output_stream_write_async() call.

	* gio/gfile.override (_wrap_g_file_replace_contents_async): Same
	as for _wrap_g_output_stream_write_async().


Modified:
   branches/pygobject-2-16/ChangeLog
   branches/pygobject-2-16/gio/gfile.override
   branches/pygobject-2-16/gio/gio.override
   branches/pygobject-2-16/gio/goutputstream.override

Modified: branches/pygobject-2-16/gio/gfile.override
==============================================================================
--- branches/pygobject-2-16/gio/gfile.override	(original)
+++ branches/pygobject-2-16/gio/gfile.override	Sun Dec 21 15:42:39 2008
@@ -1110,9 +1110,10 @@
 
     Py_INCREF(notify->callback);
     Py_XINCREF(notify->data);
+    pygio_notify_copy_buffer(notify, contents, length);
     g_file_replace_contents_async(G_FILE(self->obj),
-                                  contents,
-                                  length,
+                                  notify->buffer,
+                                  notify->buffer_size,
                                   etag,
                                   make_backup,
                                   flags,

Modified: branches/pygobject-2-16/gio/gio.override
==============================================================================
--- branches/pygobject-2-16/gio/gio.override	(original)
+++ branches/pygobject-2-16/gio/gio.override	Sun Dec 21 15:42:39 2008
@@ -36,6 +36,8 @@
 typedef struct {
     PyObject *callback;
     PyObject *data;
+    gpointer  buffer;
+    gsize     buffer_size;
 } PyGIONotify;
 
 static void
@@ -45,10 +47,22 @@
 }
 
 static void
+pygio_notify_copy_buffer(PyGIONotify *notify, gpointer buffer, gsize buffer_size)
+{
+    if (buffer_size > 0) {
+	notify->buffer = g_slice_copy(buffer_size, buffer);
+	notify->buffer_size = buffer_size;
+    }
+}
+
+static void
 pygio_free_notify(PyGIONotify *notify)
 {
     Py_XDECREF(notify->callback);
     Py_XDECREF(notify->data);
+    if (notify->buffer)
+	g_slice_free1(notify->buffer_size, notify->buffer);
+
     g_slice_free(PyGIONotify, notify);
 }
 

Modified: branches/pygobject-2-16/gio/goutputstream.override
==============================================================================
--- branches/pygobject-2-16/gio/goutputstream.override	(original)
+++ branches/pygobject-2-16/gio/goutputstream.override	Sun Dec 21 15:42:39 2008
@@ -130,9 +130,10 @@
   if (!pygio_check_cancellable(pycancellable, &cancellable))
       return NULL;
 
+  pygio_notify_copy_buffer(notify, buffer, count);
   g_output_stream_write_async(G_OUTPUT_STREAM(self->obj),
-			      buffer,
-			      count,
+			      notify->buffer,
+			      notify->buffer_size,
 			      io_priority,
 			      cancellable,
 			      (GAsyncReadyCallback)async_result_callback_marshal,



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