mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-09-06 07:58:44 +02:00
gfile: Add g_file_{copy,move}_async_with_closures
g_file_copy_async() and g_file_move_async() are written in a way that is not bindable with gobject-introspection. The progress callback data can be freed once the async callback has been called, which is convenient for C, but in language bindings the progress callback closure is currently just leaked. There is no scope annotation that fits how the progress callback should be treated: - (scope call) is correct for the sync versions of the functions, but incorrect for the async functions; the progress callback is called after the async functions return. - (scope notified) is incorrect because there is no GDestroyNotify parameter, meaning the callback will always leak. - (scope async) is incorrect because the callback is called more than once. - (scope forever) is incorrect because the callback closure could be freed after the async callback runs. This adds g_file_copy_async_with_closures() and g_file_move_async_with_closures() for the benefit of language bindings. See: GNOME/gjs#590
This commit is contained in:
committed by
Philip Withnall
parent
afcb839121
commit
64b06c633a
16
gio/gfile.h
16
gio/gfile.h
@@ -944,6 +944,14 @@ void g_file_copy_async (GFile
|
||||
gpointer progress_callback_data,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
GIO_AVAILABLE_IN_2_82
|
||||
void g_file_copy_async_with_closures (GFile *source,
|
||||
GFile *destination,
|
||||
GFileCopyFlags flags,
|
||||
int io_priority,
|
||||
GCancellable *cancellable,
|
||||
GClosure *progress_callback_closure,
|
||||
GClosure *ready_callback_closure);
|
||||
GIO_AVAILABLE_IN_ALL
|
||||
gboolean g_file_copy_finish (GFile *file,
|
||||
GAsyncResult *res,
|
||||
@@ -966,6 +974,14 @@ void g_file_move_async (GFile
|
||||
gpointer progress_callback_data,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
GIO_AVAILABLE_IN_2_82
|
||||
void g_file_move_async_with_closures (GFile *source,
|
||||
GFile *destination,
|
||||
GFileCopyFlags flags,
|
||||
int io_priority,
|
||||
GCancellable *cancellable,
|
||||
GClosure *progress_callback_closure,
|
||||
GClosure *ready_callback_closure);
|
||||
GIO_AVAILABLE_IN_2_72
|
||||
gboolean g_file_move_finish (GFile *file,
|
||||
GAsyncResult *result,
|
||||
|
Reference in New Issue
Block a user