summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog17
-rw-r--r--gio/gfile.override17
-rw-r--r--gio/gio.override13
-rw-r--r--tests/test_gio.py22
4 files changed, 55 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index a4586bf..251ecac 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
2008-08-09 Paul Pogonyshev <pogonyshev@gmx.net>
+ Bug 546591 – File.copy progress_callback does not work
+
+ * gio/gfile.override (file_progress_callback_marshal): Use
+ PyObject_CallFunction() instead of PyEval_CallFunction(). Use "K"
+ instead of "k" (the latter is not correct for 32-bit platforms).
+ Don't free 'notify' here.
+ (_wrap_g_file_copy): Free 'notify'.
+ (_wrap_g_file_move): Likewise.
+
+ * gio/gio.override (pygio_free_notify): New function.
+ (async_result_callback_marshal): Use it.
+
+ * tests/test_gio.py (TestFile.test_copy_progress.progress): New
+ test.
+
+2008-08-09 Paul Pogonyshev <pogonyshev@gmx.net>
+
Bug 546135 – GIcon and implementations improvements
* gio/gio.defs (gio.LoadableIcon.load)
diff --git a/gio/gfile.override b/gio/gfile.override
index cae5993..d7a40ee 100644
--- a/gio/gfile.override
+++ b/gio/gfile.override
@@ -33,12 +33,12 @@ file_progress_callback_marshal(goffset current_num_bytes,
state = pyg_gil_state_ensure();
if (notify->data)
- ret = PyEval_CallFunction(notify->callback, "(kkO)",
- current_num_bytes,
- total_num_bytes,
- notify->data);
+ ret = PyObject_CallFunction(notify->callback, "(KKO)",
+ current_num_bytes,
+ total_num_bytes,
+ notify->data);
else
- ret = PyObject_CallFunction(notify->callback, "(kk)",
+ ret = PyObject_CallFunction(notify->callback, "(KK)",
current_num_bytes,
total_num_bytes);
@@ -49,11 +49,6 @@ file_progress_callback_marshal(goffset current_num_bytes,
}
Py_XDECREF(ret);
-
- Py_DECREF(notify->callback);
- Py_XDECREF(notify->data);
- g_slice_free(PyGIONotify, notify);
-
pyg_gil_state_release(state);
}
%%
@@ -577,6 +572,7 @@ _wrap_g_file_copy(PyGObject *self,
notify,
&error);
+ pygio_free_notify(notify);
if (pyg_error_check(&error))
return NULL;
@@ -647,6 +643,7 @@ _wrap_g_file_move(PyGObject *self,
notify,
&error);
+ pygio_free_notify(notify);
if (pyg_error_check(&error))
return NULL;
diff --git a/gio/gio.override b/gio/gio.override
index 16c796a..92ceb6c 100644
--- a/gio/gio.override
+++ b/gio/gio.override
@@ -45,6 +45,14 @@ py_decref_callback (gpointer data)
}
static void
+pygio_free_notify(PyGIONotify *notify)
+{
+ Py_XDECREF(notify->callback);
+ Py_XDECREF(notify->data);
+ g_slice_free(PyGIONotify, notify);
+}
+
+static void
async_result_callback_marshal(GObject *source_object,
GAsyncResult *result,
PyGIONotify *notify)
@@ -71,10 +79,7 @@ async_result_callback_marshal(GObject *source_object,
}
Py_XDECREF(ret);
-
- Py_DECREF(notify->callback);
- Py_XDECREF(notify->data);
- g_slice_free(PyGIONotify, notify);
+ pygio_free_notify(notify);
pyg_gil_state_release(state);
}
diff --git a/tests/test_gio.py b/tests/test_gio.py
index 930d8fb..ad186fe 100644
--- a/tests/test_gio.py
+++ b/tests/test_gio.py
@@ -295,6 +295,28 @@ class TestFile(unittest.TestCase):
finally:
os.unlink("copy.txt")
+ # See bug 546591.
+ def test_copy_progress(self):
+ source = gio.File('file.txt')
+ destination = gio.File('copy.txt')
+
+ def progress(current, total):
+ self.assert_(isinstance(current, long))
+ self.assert_(isinstance(total, long))
+ self.assert_(0 <= current <= total)
+
+ try:
+ retval = source.copy(destination,
+ flags=gio.FILE_COPY_OVERWRITE,
+ progress_callback=progress)
+ self.failUnless(retval)
+
+ self.failUnless(os.path.exists('copy.txt'))
+ self.assertEqual(open('file.txt').read(),
+ open('copy.txt').read())
+ finally:
+ os.unlink("copy.txt")
+
def testMove(self):
if os.path.exists('move.txt'):
os.unlink("move.txt")