[glib] gio: Add g_async_result_legacy_propagate_error()
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gio: Add g_async_result_legacy_propagate_error()
- Date: Tue, 10 Jul 2012 14:50:44 +0000 (UTC)
commit f8532a13e2054e649f75ca2a58e01604be05549e
Author: Dan Winship <danw gnome org>
Date: Thu May 10 09:00:45 2012 -0400
gio: Add g_async_result_legacy_propagate_error()
Finish deprecating the "handle GSimpleAsyncResult errors in the
wrapper function" idiom (and protect against future GSimpleAsyncResult
deprecation warnings) by adding a "legacy" GAsyncResult method
to do it in those classes/methods where it had been traditionally
done.
(This applies only to wrapper methods; in cases where an _async
vmethod explicitly uses GSimpleAsyncResult, its corresponding _finish
vmethod still uses g_simple_async_result_propagate_error.)
https://bugzilla.gnome.org/show_bug.cgi?id=667375
https://bugzilla.gnome.org/show_bug.cgi?id=661767
docs/reference/gio/gio-sections.txt | 1 +
gio/gasyncinitable.c | 8 +-
gio/gasyncresult.c | 42 ++++++++
gio/gasyncresult.h | 4 +
gio/gbufferedinputstream.c | 5 +-
gio/gdrive.c | 44 ++------
gio/gfile.c | 189 +++++++++-------------------------
gio/gfileenumerator.c | 16 +--
gio/gfileinputstream.c | 9 +--
gio/gfileiostream.c | 13 +--
gio/gfileoutputstream.c | 9 +--
gio/ginputstream.c | 15 ++-
gio/gio.symbols | 1 +
gio/giostream.c | 5 +-
gio/gloadableicon.c | 10 +--
gio/gmount.c | 48 ++-------
gio/goutputstream.c | 24 ++---
gio/gresolver.c | 24 ++---
gio/gvolume.c | 24 +----
19 files changed, 180 insertions(+), 311 deletions(-)
---
diff --git a/docs/reference/gio/gio-sections.txt b/docs/reference/gio/gio-sections.txt
index 79b5dfc..f0d4990 100644
--- a/docs/reference/gio/gio-sections.txt
+++ b/docs/reference/gio/gio-sections.txt
@@ -1199,6 +1199,7 @@ GAsyncResultIface
GAsyncReadyCallback
g_async_result_get_user_data
g_async_result_get_source_object
+g_async_result_legacy_propagate_error
<SUBSECTION Standard>
G_ASYNC_RESULT
G_IS_ASYNC_RESULT
diff --git a/gio/gasyncinitable.c b/gio/gasyncinitable.c
index b13fac6..e8cf8c9 100644
--- a/gio/gasyncinitable.c
+++ b/gio/gasyncinitable.c
@@ -248,12 +248,8 @@ g_async_initable_init_finish (GAsyncInitable *initable,
g_return_val_if_fail (G_IS_ASYNC_INITABLE (initable), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (res), FALSE);
- if (G_IS_SIMPLE_ASYNC_RESULT (res))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- }
+ if (g_async_result_legacy_propagate_error (res, error))
+ return FALSE;
iface = G_ASYNC_INITABLE_GET_IFACE (initable);
diff --git a/gio/gasyncresult.c b/gio/gasyncresult.c
index adf6f9c..b578efc 100644
--- a/gio/gasyncresult.c
+++ b/gio/gasyncresult.c
@@ -22,6 +22,7 @@
#include "config.h"
#include "gasyncresult.h"
+#include "gsimpleasyncresult.h"
#include "glibintl.h"
@@ -152,3 +153,44 @@ g_async_result_get_source_object (GAsyncResult *res)
return (* iface->get_source_object) (res);
}
+
+/**
+ * g_async_result_legacy_propagate_error:
+ * @result: a #GAsyncResult
+ * @dest: (out): a location to propagate the error to.
+ *
+ * If @result is a #GSimpleAsyncResult, this is equivalent to
+ * g_simple_async_result_propagate_error(). Otherwise it returns
+ * %FALSE.
+ *
+ * This can be used for legacy error handling in async
+ * <literal>_finish ()</literal> wrapper functions that traditionally
+ * handled #GSimpleAsyncResult error returns themselves rather than
+ * calling into the virtual method. This should not be used in new
+ * code; #GAsyncResult errors that are set by virtual methods should
+ * also be extracted by virtual methods, to enable subclasses to chain
+ * up correctly.
+ *
+ * Returns: %TRUE if @error is has been filled in with an error from
+ * @res, %FALSE if not.
+ *
+ * Since: 2.34
+ **/
+gboolean
+g_async_result_legacy_propagate_error (GAsyncResult *res,
+ GError **error)
+{
+ /* This doesn't use a vmethod, because it's only for code that used
+ * to use GSimpleAsyncResult. (But it's a GAsyncResult method so
+ * that callers don't need to worry about GSimpleAsyncResult
+ * deprecation warnings in the future.)
+ */
+
+ if (G_IS_SIMPLE_ASYNC_RESULT (res))
+ {
+ return g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res),
+ error);
+ }
+ else
+ return FALSE;
+}
diff --git a/gio/gasyncresult.h b/gio/gasyncresult.h
index ade63c4..773d57e 100644
--- a/gio/gasyncresult.h
+++ b/gio/gasyncresult.h
@@ -68,6 +68,10 @@ GType g_async_result_get_type (void) G_GNUC_CONST;
gpointer g_async_result_get_user_data (GAsyncResult *res);
GObject *g_async_result_get_source_object (GAsyncResult *res);
+GLIB_AVAILABLE_IN_2_34
+gboolean g_async_result_legacy_propagate_error (GAsyncResult *res,
+ GError **error);
+
G_END_DECLS
#endif /* __G_ASYNC_RESULT_H__ */
diff --git a/gio/gbufferedinputstream.c b/gio/gbufferedinputstream.c
index 139199d..b8e1b11 100644
--- a/gio/gbufferedinputstream.c
+++ b/gio/gbufferedinputstream.c
@@ -548,11 +548,12 @@ g_buffered_input_stream_fill_finish (GBufferedInputStream *stream,
g_return_val_if_fail (G_IS_BUFFERED_INPUT_STREAM (stream), -1);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), -1);
+ if (g_async_result_legacy_propagate_error (result, error))
+ return -1;
+
if (G_IS_SIMPLE_ASYNC_RESULT (result))
{
simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return -1;
/* Special case read of 0 bytes */
if (g_simple_async_result_get_source_tag (simple) == g_buffered_input_stream_fill_async)
diff --git a/gio/gdrive.c b/gio/gdrive.c
index bc4405a..0e8c8ef 100644
--- a/gio/gdrive.c
+++ b/gio/gdrive.c
@@ -391,13 +391,9 @@ g_drive_eject_finish (GDrive *drive,
g_return_val_if_fail (G_IS_DRIVE (drive), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- }
-
+ if (g_async_result_legacy_propagate_error (result, error))
+ return FALSE;
+
iface = G_DRIVE_GET_IFACE (drive);
return (* iface->eject_finish) (drive, result, error);
@@ -475,12 +471,8 @@ g_drive_eject_with_operation_finish (GDrive *drive,
g_return_val_if_fail (G_IS_DRIVE (drive), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- }
+ if (g_async_result_legacy_propagate_error (result, error))
+ return FALSE;
iface = G_DRIVE_GET_IFACE (drive);
if (iface->eject_with_operation_finish != NULL)
@@ -547,13 +539,9 @@ g_drive_poll_for_media_finish (GDrive *drive,
g_return_val_if_fail (G_IS_DRIVE (drive), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- }
-
+ if (g_async_result_legacy_propagate_error (result, error))
+ return FALSE;
+
iface = G_DRIVE_GET_IFACE (drive);
return (* iface->poll_for_media_finish) (drive, result, error);
@@ -755,12 +743,8 @@ g_drive_start_finish (GDrive *drive,
g_return_val_if_fail (G_IS_DRIVE (drive), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- }
+ if (g_async_result_legacy_propagate_error (result, error))
+ return FALSE;
iface = G_DRIVE_GET_IFACE (drive);
@@ -858,12 +842,8 @@ g_drive_stop_finish (GDrive *drive,
g_return_val_if_fail (G_IS_DRIVE (drive), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- }
+ if (g_async_result_legacy_propagate_error (result, error))
+ return FALSE;
iface = G_DRIVE_GET_IFACE (drive);
diff --git a/gio/gfile.c b/gio/gfile.c
index 69f4100..abc7e27 100644
--- a/gio/gfile.c
+++ b/gio/gfile.c
@@ -946,12 +946,8 @@ g_file_enumerate_children_finish (GFile *file,
g_return_val_if_fail (G_IS_FILE (file), NULL);
g_return_val_if_fail (G_IS_ASYNC_RESULT (res), NULL);
- if (G_IS_SIMPLE_ASYNC_RESULT (res))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
- if (g_simple_async_result_propagate_error (simple, error))
- return NULL;
- }
+ if (g_async_result_legacy_propagate_error (res, error))
+ return NULL;
iface = G_FILE_GET_IFACE (file);
return (* iface->enumerate_children_finish) (file, res, error);
@@ -1175,12 +1171,8 @@ g_file_query_info_finish (GFile *file,
g_return_val_if_fail (G_IS_FILE (file), NULL);
g_return_val_if_fail (G_IS_ASYNC_RESULT (res), NULL);
- if (G_IS_SIMPLE_ASYNC_RESULT (res))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
- if (g_simple_async_result_propagate_error (simple, error))
- return NULL;
- }
+ if (g_async_result_legacy_propagate_error (res, error))
+ return NULL;
iface = G_FILE_GET_IFACE (file);
return (* iface->query_info_finish) (file, res, error);
@@ -1309,12 +1301,8 @@ g_file_query_filesystem_info_finish (GFile *file,
g_return_val_if_fail (G_IS_FILE (file), NULL);
g_return_val_if_fail (G_IS_ASYNC_RESULT (res), NULL);
- if (G_IS_SIMPLE_ASYNC_RESULT (res))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
- if (g_simple_async_result_propagate_error (simple, error))
- return NULL;
- }
+ if (g_async_result_legacy_propagate_error (res, error))
+ return NULL;
iface = G_FILE_GET_IFACE (file);
return (* iface->query_filesystem_info_finish) (file, res, error);
@@ -1423,12 +1411,8 @@ g_file_find_enclosing_mount_finish (GFile *file,
g_return_val_if_fail (G_IS_FILE (file), NULL);
g_return_val_if_fail (G_IS_ASYNC_RESULT (res), NULL);
- if (G_IS_SIMPLE_ASYNC_RESULT (res))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
- if (g_simple_async_result_propagate_error (simple, error))
- return NULL;
- }
+ if (g_async_result_legacy_propagate_error (res, error))
+ return NULL;
iface = G_FILE_GET_IFACE (file);
return (* iface->find_enclosing_mount_finish) (file, res, error);
@@ -1902,12 +1886,8 @@ g_file_read_finish (GFile *file,
g_return_val_if_fail (G_IS_FILE (file), NULL);
g_return_val_if_fail (G_IS_ASYNC_RESULT (res), NULL);
- if (G_IS_SIMPLE_ASYNC_RESULT (res))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
- if (g_simple_async_result_propagate_error (simple, error))
- return NULL;
- }
+ if (g_async_result_legacy_propagate_error (res, error))
+ return NULL;
iface = G_FILE_GET_IFACE (file);
return (* iface->read_finish) (file, res, error);
@@ -1974,12 +1954,8 @@ g_file_append_to_finish (GFile *file,
g_return_val_if_fail (G_IS_FILE (file), NULL);
g_return_val_if_fail (G_IS_ASYNC_RESULT (res), NULL);
- if (G_IS_SIMPLE_ASYNC_RESULT (res))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
- if (g_simple_async_result_propagate_error (simple, error))
- return NULL;
- }
+ if (g_async_result_legacy_propagate_error (res, error))
+ return NULL;
iface = G_FILE_GET_IFACE (file);
return (* iface->append_to_finish) (file, res, error);
@@ -2047,12 +2023,8 @@ g_file_create_finish (GFile *file,
g_return_val_if_fail (G_IS_FILE (file), NULL);
g_return_val_if_fail (G_IS_ASYNC_RESULT (res), NULL);
- if (G_IS_SIMPLE_ASYNC_RESULT (res))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
- if (g_simple_async_result_propagate_error (simple, error))
- return NULL;
- }
+ if (g_async_result_legacy_propagate_error (res, error))
+ return NULL;
iface = G_FILE_GET_IFACE (file);
return (* iface->create_finish) (file, res, error);
@@ -2127,13 +2099,9 @@ g_file_replace_finish (GFile *file,
g_return_val_if_fail (G_IS_FILE (file), NULL);
g_return_val_if_fail (G_IS_ASYNC_RESULT (res), NULL);
- if (G_IS_SIMPLE_ASYNC_RESULT (res))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
- if (g_simple_async_result_propagate_error (simple, error))
- return NULL;
- }
-
+ if (g_async_result_legacy_propagate_error (res, error))
+ return NULL;
+
iface = G_FILE_GET_IFACE (file);
return (* iface->replace_finish) (file, res, error);
}
@@ -2201,13 +2169,9 @@ g_file_open_readwrite_finish (GFile *file,
g_return_val_if_fail (G_IS_FILE (file), NULL);
g_return_val_if_fail (G_IS_ASYNC_RESULT (res), NULL);
- if (G_IS_SIMPLE_ASYNC_RESULT (res))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
- if (g_simple_async_result_propagate_error (simple, error))
- return NULL;
- }
-
+ if (g_async_result_legacy_propagate_error (res, error))
+ return NULL;
+
iface = G_FILE_GET_IFACE (file);
return (* iface->open_readwrite_finish) (file, res, error);
}
@@ -2279,13 +2243,9 @@ g_file_create_readwrite_finish (GFile *file,
g_return_val_if_fail (G_IS_FILE (file), NULL);
g_return_val_if_fail (G_IS_ASYNC_RESULT (res), NULL);
- if (G_IS_SIMPLE_ASYNC_RESULT (res))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
- if (g_simple_async_result_propagate_error (simple, error))
- return NULL;
- }
-
+ if (g_async_result_legacy_propagate_error (res, error))
+ return NULL;
+
iface = G_FILE_GET_IFACE (file);
return (* iface->create_readwrite_finish) (file, res, error);
}
@@ -2363,13 +2323,9 @@ g_file_replace_readwrite_finish (GFile *file,
g_return_val_if_fail (G_IS_FILE (file), NULL);
g_return_val_if_fail (G_IS_ASYNC_RESULT (res), NULL);
- if (G_IS_SIMPLE_ASYNC_RESULT (res))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
- if (g_simple_async_result_propagate_error (simple, error))
- return NULL;
- }
-
+ if (g_async_result_legacy_propagate_error (res, error))
+ return NULL;
+
iface = G_FILE_GET_IFACE (file);
return (* iface->replace_readwrite_finish) (file, res, error);
}
@@ -3181,13 +3137,8 @@ g_file_copy_finish (GFile *file,
g_return_val_if_fail (G_IS_FILE (file), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (res), FALSE);
- if (G_IS_SIMPLE_ASYNC_RESULT (res))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
-
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- }
+ if (g_async_result_legacy_propagate_error (res, error))
+ return FALSE;
iface = G_FILE_GET_IFACE (file);
return (* iface->copy_finish) (file, res, error);
@@ -3715,12 +3666,8 @@ g_file_set_display_name_finish (GFile *file,
g_return_val_if_fail (G_IS_FILE (file), NULL);
g_return_val_if_fail (G_IS_ASYNC_RESULT (res), NULL);
- if (G_IS_SIMPLE_ASYNC_RESULT (res))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
- if (g_simple_async_result_propagate_error (simple, error))
- return NULL;
- }
+ if (g_async_result_legacy_propagate_error (res, error))
+ return NULL;
iface = G_FILE_GET_IFACE (file);
return (* iface->set_display_name_finish) (file, res, error);
@@ -4317,12 +4264,8 @@ g_file_mount_mountable_finish (GFile *file,
g_return_val_if_fail (G_IS_FILE (file), NULL);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), NULL);
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return NULL;
- }
+ if (g_async_result_legacy_propagate_error (result, error))
+ return NULL;
iface = G_FILE_GET_IFACE (file);
return (* iface->mount_mountable_finish) (file, result, error);
@@ -4404,12 +4347,8 @@ g_file_unmount_mountable_finish (GFile *file,
g_return_val_if_fail (G_IS_FILE (file), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- }
+ if (g_async_result_legacy_propagate_error (result, error))
+ return FALSE;
iface = G_FILE_GET_IFACE (file);
return (* iface->unmount_mountable_finish) (file, result, error);
@@ -4501,12 +4440,8 @@ g_file_unmount_mountable_with_operation_finish (GFile *file,
g_return_val_if_fail (G_IS_FILE (file), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- }
+ if (g_async_result_legacy_propagate_error (result, error))
+ return FALSE;
iface = G_FILE_GET_IFACE (file);
if (iface->unmount_mountable_with_operation_finish != NULL)
@@ -4589,13 +4524,9 @@ g_file_eject_mountable_finish (GFile *file,
g_return_val_if_fail (G_IS_FILE (file), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- }
-
+ if (g_async_result_legacy_propagate_error (result, error))
+ return FALSE;
+
iface = G_FILE_GET_IFACE (file);
return (* iface->eject_mountable_finish) (file, result, error);
}
@@ -4684,12 +4615,8 @@ g_file_eject_mountable_with_operation_finish (GFile *file,
g_return_val_if_fail (G_IS_FILE (file), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- }
+ if (g_async_result_legacy_propagate_error (result, error))
+ return FALSE;
iface = G_FILE_GET_IFACE (file);
if (iface->eject_mountable_with_operation_finish != NULL)
@@ -6130,13 +6057,9 @@ g_file_mount_enclosing_volume_finish (GFile *location,
g_return_val_if_fail (G_IS_FILE (location), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- }
-
+ if (g_async_result_legacy_propagate_error (result, error))
+ return FALSE;
+
iface = G_FILE_GET_IFACE (location);
return (* iface->mount_enclosing_volume_finish) (location, result, error);
@@ -7078,12 +7001,8 @@ g_file_start_mountable_finish (GFile *file,
g_return_val_if_fail (G_IS_FILE (file), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- }
+ if (g_async_result_legacy_propagate_error (result, error))
+ return FALSE;
iface = G_FILE_GET_IFACE (file);
return (* iface->start_mountable_finish) (file, result, error);
@@ -7168,12 +7087,8 @@ g_file_stop_mountable_finish (GFile *file,
g_return_val_if_fail (G_IS_FILE (file), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- }
+ if (g_async_result_legacy_propagate_error (result, error))
+ return FALSE;
iface = G_FILE_GET_IFACE (file);
return (* iface->stop_mountable_finish) (file, result, error);
@@ -7252,12 +7167,8 @@ g_file_poll_mountable_finish (GFile *file,
g_return_val_if_fail (G_IS_FILE (file), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- }
+ if (g_async_result_legacy_propagate_error (result, error))
+ return FALSE;
iface = G_FILE_GET_IFACE (file);
return (* iface->poll_mountable_finish) (file, result, error);
diff --git a/gio/gfileenumerator.c b/gio/gfileenumerator.c
index fa6863d..b4f7424 100644
--- a/gio/gfileenumerator.c
+++ b/gio/gfileenumerator.c
@@ -405,11 +405,12 @@ g_file_enumerator_next_files_finish (GFileEnumerator *enumerator,
g_return_val_if_fail (G_IS_FILE_ENUMERATOR (enumerator), NULL);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), NULL);
+ if (g_async_result_legacy_propagate_error (result, error))
+ return NULL;
+
if (G_IS_SIMPLE_ASYNC_RESULT (result))
{
simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return NULL;
/* Special case read of 0 files */
if (g_simple_async_result_get_source_tag (simple) == g_file_enumerator_next_files_async)
@@ -515,19 +516,14 @@ g_file_enumerator_close_finish (GFileEnumerator *enumerator,
GAsyncResult *result,
GError **error)
{
- GSimpleAsyncResult *simple;
GFileEnumeratorClass *class;
g_return_val_if_fail (G_IS_FILE_ENUMERATOR (enumerator), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- }
-
+ if (g_async_result_legacy_propagate_error (result, error))
+ return FALSE;
+
class = G_FILE_ENUMERATOR_GET_CLASS (enumerator);
return class->close_finish (enumerator, result, error);
}
diff --git a/gio/gfileinputstream.c b/gio/gfileinputstream.c
index 86d6d36..0957852 100644
--- a/gio/gfileinputstream.c
+++ b/gio/gfileinputstream.c
@@ -246,18 +246,13 @@ g_file_input_stream_query_info_finish (GFileInputStream *stream,
GAsyncResult *result,
GError **error)
{
- GSimpleAsyncResult *simple;
GFileInputStreamClass *class;
g_return_val_if_fail (G_IS_FILE_INPUT_STREAM (stream), NULL);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), NULL);
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return NULL;
- }
+ if (g_async_result_legacy_propagate_error (result, error))
+ return NULL;
class = G_FILE_INPUT_STREAM_GET_CLASS (stream);
return class->query_info_finish (stream, result, error);
diff --git a/gio/gfileiostream.c b/gio/gfileiostream.c
index 85a8dd9..58adb6e 100644
--- a/gio/gfileiostream.c
+++ b/gio/gfileiostream.c
@@ -257,21 +257,16 @@ g_file_io_stream_query_info_async (GFileIOStream *stream,
**/
GFileInfo *
g_file_io_stream_query_info_finish (GFileIOStream *stream,
- GAsyncResult *result,
- GError **error)
+ GAsyncResult *result,
+ GError **error)
{
- GSimpleAsyncResult *simple;
GFileIOStreamClass *class;
g_return_val_if_fail (G_IS_FILE_IO_STREAM (stream), NULL);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), NULL);
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return NULL;
- }
+ if (g_async_result_legacy_propagate_error (result, error))
+ return NULL;
class = G_FILE_IO_STREAM_GET_CLASS (stream);
return class->query_info_finish (stream, result, error);
diff --git a/gio/gfileoutputstream.c b/gio/gfileoutputstream.c
index 2670e0e..640abe2 100644
--- a/gio/gfileoutputstream.c
+++ b/gio/gfileoutputstream.c
@@ -256,18 +256,13 @@ g_file_output_stream_query_info_finish (GFileOutputStream *stream,
GAsyncResult *result,
GError **error)
{
- GSimpleAsyncResult *simple;
GFileOutputStreamClass *class;
g_return_val_if_fail (G_IS_FILE_OUTPUT_STREAM (stream), NULL);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), NULL);
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return NULL;
- }
+ if (g_async_result_legacy_propagate_error (result, error))
+ return NULL;
class = G_FILE_OUTPUT_STREAM_GET_CLASS (stream);
return class->query_info_finish (stream, result, error);
diff --git a/gio/ginputstream.c b/gio/ginputstream.c
index 960811f..db90aeb 100644
--- a/gio/ginputstream.c
+++ b/gio/ginputstream.c
@@ -655,11 +655,12 @@ g_input_stream_read_finish (GInputStream *stream,
g_return_val_if_fail (G_IS_INPUT_STREAM (stream), -1);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), -1);
+ if (g_async_result_legacy_propagate_error (result, error))
+ return -1;
+
if (G_IS_SIMPLE_ASYNC_RESULT (result))
{
simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return -1;
/* Special case read of 0 bytes */
if (g_simple_async_result_get_source_tag (simple) == g_input_stream_read_async)
@@ -894,11 +895,12 @@ g_input_stream_skip_finish (GInputStream *stream,
g_return_val_if_fail (G_IS_INPUT_STREAM (stream), -1);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), -1);
+ if (g_async_result_legacy_propagate_error (result, error))
+ return -1;
+
if (G_IS_SIMPLE_ASYNC_RESULT (result))
{
simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return -1;
/* Special case skip of 0 bytes */
if (g_simple_async_result_get_source_tag (simple) == g_input_stream_skip_async)
@@ -992,11 +994,12 @@ g_input_stream_close_finish (GInputStream *stream,
g_return_val_if_fail (G_IS_INPUT_STREAM (stream), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
+ if (g_async_result_legacy_propagate_error (result, error))
+ return FALSE;
+
if (G_IS_SIMPLE_ASYNC_RESULT (result))
{
simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
/* Special case already closed */
if (g_simple_async_result_get_source_tag (simple) == g_input_stream_close_async)
diff --git a/gio/gio.symbols b/gio/gio.symbols
index fcba6a3..4025da8 100644
--- a/gio/gio.symbols
+++ b/gio/gio.symbols
@@ -119,6 +119,7 @@ g_desktop_app_info_set_desktop_env
g_async_result_get_type
g_async_result_get_user_data
g_async_result_get_source_object
+g_async_result_legacy_propagate_error
g_buffered_input_stream_get_type
g_buffered_input_stream_new
g_buffered_input_stream_new_sized
diff --git a/gio/giostream.c b/gio/giostream.c
index e318c4a..d2f40c4 100644
--- a/gio/giostream.c
+++ b/gio/giostream.c
@@ -521,11 +521,12 @@ g_io_stream_close_finish (GIOStream *stream,
g_return_val_if_fail (G_IS_IO_STREAM (stream), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
+ if (g_async_result_legacy_propagate_error (result, error))
+ return FALSE;
+
if (G_IS_SIMPLE_ASYNC_RESULT (result))
{
simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
/* Special case already closed */
if (g_simple_async_result_get_source_tag (simple) == g_io_stream_close_async)
diff --git a/gio/gloadableicon.c b/gio/gloadableicon.c
index 66f9770..e8eec2d 100644
--- a/gio/gloadableicon.c
+++ b/gio/gloadableicon.c
@@ -141,13 +141,9 @@ g_loadable_icon_load_finish (GLoadableIcon *icon,
g_return_val_if_fail (G_IS_LOADABLE_ICON (icon), NULL);
g_return_val_if_fail (G_IS_ASYNC_RESULT (res), NULL);
- if (G_IS_SIMPLE_ASYNC_RESULT (res))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
- if (g_simple_async_result_propagate_error (simple, error))
- return NULL;
- }
-
+ if (g_async_result_legacy_propagate_error (res, error))
+ return NULL;
+
iface = G_LOADABLE_ICON_GET_IFACE (icon);
return (* iface->load_finish) (icon, res, type, error);
diff --git a/gio/gmount.c b/gio/gmount.c
index 3249123..fca17f5 100644
--- a/gio/gmount.c
+++ b/gio/gmount.c
@@ -392,12 +392,8 @@ g_mount_unmount_finish (GMount *mount,
g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- }
+ if (g_async_result_legacy_propagate_error (result, error))
+ return FALSE;
iface = G_MOUNT_GET_IFACE (mount);
return (* iface->unmount_finish) (mount, result, error);
@@ -471,12 +467,8 @@ g_mount_eject_finish (GMount *mount,
g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- }
+ if (g_async_result_legacy_propagate_error (result, error))
+ return FALSE;
iface = G_MOUNT_GET_IFACE (mount);
return (* iface->eject_finish) (mount, result, error);
@@ -555,12 +547,8 @@ g_mount_unmount_with_operation_finish (GMount *mount,
g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- }
+ if (g_async_result_legacy_propagate_error (result, error))
+ return FALSE;
iface = G_MOUNT_GET_IFACE (mount);
if (iface->unmount_with_operation_finish != NULL)
@@ -642,12 +630,8 @@ g_mount_eject_with_operation_finish (GMount *mount,
g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- }
+ if (g_async_result_legacy_propagate_error (result, error))
+ return FALSE;
iface = G_MOUNT_GET_IFACE (mount);
if (iface->eject_with_operation_finish != NULL)
@@ -728,12 +712,8 @@ g_mount_remount_finish (GMount *mount,
g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- }
+ if (g_async_result_legacy_propagate_error (result, error))
+ return FALSE;
iface = G_MOUNT_GET_IFACE (mount);
return (* iface->remount_finish) (mount, result, error);
@@ -818,12 +798,8 @@ g_mount_guess_content_type_finish (GMount *mount,
g_return_val_if_fail (G_IS_MOUNT (mount), NULL);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), NULL);
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return NULL;
- }
+ if (g_async_result_legacy_propagate_error (result, error))
+ return NULL;
iface = G_MOUNT_GET_IFACE (mount);
return (* iface->guess_content_type_finish) (mount, result, error);
diff --git a/gio/goutputstream.c b/gio/goutputstream.c
index d512bbb..a619c05 100644
--- a/gio/goutputstream.c
+++ b/gio/goutputstream.c
@@ -841,11 +841,12 @@ g_output_stream_write_finish (GOutputStream *stream,
g_return_val_if_fail (G_IS_OUTPUT_STREAM (stream), -1);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), -1);
+ if (g_async_result_legacy_propagate_error (result, error))
+ return -1;
+
if (G_IS_SIMPLE_ASYNC_RESULT (result))
{
simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return -1;
/* Special case writes of 0 bytes */
if (g_simple_async_result_get_source_tag (simple) == g_output_stream_write_async)
@@ -1074,18 +1075,13 @@ g_output_stream_splice_finish (GOutputStream *stream,
GAsyncResult *result,
GError **error)
{
- GSimpleAsyncResult *simple;
GOutputStreamClass *class;
g_return_val_if_fail (G_IS_OUTPUT_STREAM (stream), -1);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), -1);
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return -1;
- }
+ if (g_async_result_legacy_propagate_error (result, error))
+ return -1;
class = G_OUTPUT_STREAM_GET_CLASS (stream);
return class->splice_finish (stream, result, error);
@@ -1171,11 +1167,12 @@ g_output_stream_flush_finish (GOutputStream *stream,
g_return_val_if_fail (G_IS_OUTPUT_STREAM (stream), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
+ if (g_async_result_legacy_propagate_error (result, error))
+ return FALSE;
+
if (G_IS_SIMPLE_ASYNC_RESULT (result))
{
simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
/* Special case default implementation */
if (g_simple_async_result_get_source_tag (simple) == g_output_stream_flush_async)
@@ -1293,11 +1290,12 @@ g_output_stream_close_finish (GOutputStream *stream,
g_return_val_if_fail (G_IS_OUTPUT_STREAM (stream), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
+ if (g_async_result_legacy_propagate_error (result, error))
+ return FALSE;
+
if (G_IS_SIMPLE_ASYNC_RESULT (result))
{
simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
/* Special case already closed */
if (g_simple_async_result_get_source_tag (simple) == g_output_stream_close_async)
diff --git a/gio/gresolver.c b/gio/gresolver.c
index efebd5a..22f815f 100644
--- a/gio/gresolver.c
+++ b/gio/gresolver.c
@@ -445,13 +445,13 @@ g_resolver_lookup_by_name_finish (GResolver *resolver,
g_return_val_if_fail (G_IS_RESOLVER (resolver), NULL);
+ if (g_async_result_legacy_propagate_error (result, error))
+ return NULL;
+
if (G_IS_SIMPLE_ASYNC_RESULT (result))
{
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return NULL;
-
/* Handle the stringified-IP-addr case */
if (g_simple_async_result_get_source_tag (simple) == g_resolver_lookup_by_name_async)
{
@@ -581,13 +581,8 @@ g_resolver_lookup_by_address_finish (GResolver *resolver,
{
g_return_val_if_fail (G_IS_RESOLVER (resolver), NULL);
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
-
- if (g_simple_async_result_propagate_error (simple, error))
- return NULL;
- }
+ if (g_async_result_legacy_propagate_error (result, error))
+ return NULL;
return G_RESOLVER_GET_CLASS (resolver)->
lookup_by_address_finish (resolver, result, error);
@@ -741,13 +736,8 @@ g_resolver_lookup_service_finish (GResolver *resolver,
{
g_return_val_if_fail (G_IS_RESOLVER (resolver), NULL);
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
-
- if (g_simple_async_result_propagate_error (simple, error))
- return NULL;
- }
+ if (g_async_result_legacy_propagate_error (result, error))
+ return NULL;
return G_RESOLVER_GET_CLASS (resolver)->
lookup_service_finish (resolver, result, error);
diff --git a/gio/gvolume.c b/gio/gvolume.c
index 97f9485..fb157d4 100644
--- a/gio/gvolume.c
+++ b/gio/gvolume.c
@@ -363,12 +363,8 @@ g_volume_mount_finish (GVolume *volume,
g_return_val_if_fail (G_IS_VOLUME (volume), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- }
+ if (g_async_result_legacy_propagate_error (result, error))
+ return FALSE;
iface = G_VOLUME_GET_IFACE (volume);
return (* iface->mount_finish) (volume, result, error);
@@ -436,12 +432,8 @@ g_volume_eject_finish (GVolume *volume,
g_return_val_if_fail (G_IS_VOLUME (volume), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- }
+ if (g_async_result_legacy_propagate_error (result, error))
+ return FALSE;
iface = G_VOLUME_GET_IFACE (volume);
return (* iface->eject_finish) (volume, result, error);
@@ -519,12 +511,8 @@ g_volume_eject_with_operation_finish (GVolume *volume,
g_return_val_if_fail (G_IS_VOLUME (volume), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- }
+ if (g_async_result_legacy_propagate_error (result, error))
+ return FALSE;
iface = G_VOLUME_GET_IFACE (volume);
if (iface->eject_with_operation_finish != NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]