gio: handle GSimpleAsyncResult errors in _finish vmethods

Originally, the standard idiom with GSimpleAsyncResult was to handle
all errors in the _finish wrapper function, so that vmethods only had
to deal with successful results. But this means that chaining up to a
parent _finish vmethod won't work correctly. Fix this by also checking
for errors in all the relevant vmethods. (We have to redundantly check
in both the vmethod and the wrapper to preserve compatibility.)

https://bugzilla.gnome.org/show_bug.cgi?id=667375
https://bugzilla.gnome.org/show_bug.cgi?id=661767
This commit is contained in:
Dan Winship
2012-06-11 13:44:19 -04:00
parent a98d26c9bb
commit 538b2f106d
10 changed files with 104 additions and 14 deletions

View File

@@ -1227,6 +1227,9 @@ g_input_stream_real_read_finish (GInputStream *stream,
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) ==
g_input_stream_real_read_async);
if (g_simple_async_result_propagate_error (simple, error))
return -1;
op = g_simple_async_result_get_op_res_gpointer (simple);
return op->count_read;
@@ -1378,6 +1381,10 @@ g_input_stream_real_skip_finish (GInputStream *stream,
SkipData *op;
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_input_stream_real_skip_async);
if (g_simple_async_result_propagate_error (simple, error))
return -1;
op = g_simple_async_result_get_op_res_gpointer (simple);
return op->count_skipped;
}
@@ -1434,6 +1441,11 @@ g_input_stream_real_close_finish (GInputStream *stream,
GError **error)
{
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_input_stream_real_close_async);
if (g_simple_async_result_propagate_error (simple, error))
return FALSE;
return TRUE;
}