[yelp] Avoid activating ourselves recursively



commit adb5cce6b8f35a262f7efa08dc78f35db2b9d5e7
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Mar 2 17:44:43 2015 -0500

    Avoid activating ourselves recursively
    
    We consider INFO:foobar an 'external uri', and call
    g_app_info_launch_default_for_uri on it. Which is bad,
    since GIO promptly determines the default handler for INFO:
    uris to be...yelp. Avoid this by manually looking up the
    default handler, and ignoring it if it appears to be yelp.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=745407

 libyelp/yelp-view.c |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/libyelp/yelp-view.c b/libyelp/yelp-view.c
index 4334be6..67afd0a 100644
--- a/libyelp/yelp-view.c
+++ b/libyelp/yelp-view.c
@@ -728,7 +728,27 @@ view_external_uri (YelpView *view,
                    YelpUri  *uri)
 {
     gchar *struri = yelp_uri_get_canonical_uri (uri);
-    g_app_info_launch_default_for_uri (struri, NULL, NULL);
+    gchar *uri_scheme;
+    GAppInfo *app_info = NULL;
+
+    uri_scheme = g_uri_parse_scheme (struri);
+    if (uri_scheme && *uri_scheme)
+      app_info = g_app_info_get_default_for_uri_scheme (uri_scheme);
+    g_free (uri_scheme);
+
+    if (app_info)
+      {
+        if (!strstr (g_app_info_get_executable (app_info), "yelp"))
+          {
+            GList l;
+
+            l.data = struri;
+            l.next = l.prev = NULL;
+            g_app_info_launch_uris (app_info, &l, NULL, NULL);
+          }
+
+        g_object_unref (app_info);
+      }
     g_free (struri);
     return TRUE;
 }


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