[glib] gappinfo: Clear previously set error before calling portal



commit 3e2187975d4d620630cc8c655d36a92ec423c632
Author: Timm Bäder <mail baedert org>
Date:   Sat Apr 29 14:25:36 2017 +0200

    gappinfo: Clear previously set error before calling portal
    
    Otherwise, we might end up returning TRUE from
    g_app_info_launch_default_for_uri but with a set error parameter. This
    will lead to confusing results depending on how the caller checks for
    errors. Checking error != NULL indicats the call failed but checking the
    return value indicates that it succeeded.

 gio/gappinfo.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/gio/gappinfo.c b/gio/gappinfo.c
index 4c8c288..ba58155 100644
--- a/gio/gappinfo.c
+++ b/gio/gappinfo.c
@@ -984,7 +984,12 @@ g_app_info_launch_default_for_uri (const char         *uri,
 
 #ifdef G_OS_UNIX
   if (glib_should_use_portal ())
-    return launch_default_with_portal (uri, launch_context, error);
+    {
+      /* Reset any error previously set by launch_default_for_uri */
+      g_clear_error (error);
+
+      return launch_default_with_portal (uri, launch_context, error);
+    }
 #endif
 
   return FALSE;


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