[glib] gapplication: never set the prgname to the app id



commit fcb30409ec7f5d2903f5f944c8b0b52fdffaab12
Author: Lars Uebernickel <lars uebernickel canonical com>
Date:   Wed Feb 4 11:01:41 2015 +0100

    gapplication: never set the prgname to the app id
    
    GApplication set the prgname to the application's id when it was running
    in service mode. This broke with the addition of new --app-id option,
    because g_set_prgname() was called before parsing the options. Calling
    it after option parsing doesn't work, because GOptionContext sets
    prgname to argv[0] unconditionally.
    
    Instead of changing the semantics of GOptionContext, simply remove this
    functionality from GApplication. It is very unusual to have the prgname
    set to the app id instead of the binary's name and might confuse people
    when looking at logs etc.
    
    When overriding local_command_line() from a subclass,
    g_option_context_parse() might never be invokded. Thus, continue setting
    the prgname to argv[0] in GApplication.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=743933

 gio/gapplication.c |   23 ++++++-----------------
 1 files changed, 6 insertions(+), 17 deletions(-)
---
diff --git a/gio/gapplication.c b/gio/gapplication.c
index 7533ae2..f4a65fe 100644
--- a/gio/gapplication.c
+++ b/gio/gapplication.c
@@ -2198,11 +2198,7 @@ g_application_open (GApplication  *application,
  * use.
  *
  * This function sets the prgname (g_set_prgname()), if not already set,
- * to the basename of argv[0].  Since 2.38, if %G_APPLICATION_IS_SERVICE
- * is specified, the prgname is set to the application ID.  The main
- * impact of this is is that the wmclass of windows created by Gtk+ will
- * be set accordingly, which helps the window manager determine which
- * application is showing the window.
+ * to the basename of argv[0].
  *
  * Since 2.40, applications that are not explicitly flagged as services
  * or launchers (ie: neither %G_APPLICATION_IS_SERVICE or
@@ -2250,20 +2246,13 @@ g_application_run (GApplication  *application,
   }
 #endif
 
-  if (g_get_prgname () == NULL)
+  if (g_get_prgname () == NULL && argc > 0)
     {
-      if (application->priv->flags & G_APPLICATION_IS_SERVICE)
-        {
-          g_set_prgname (application->priv->id);
-        }
-      else if (argc > 0)
-        {
-          gchar *prgname;
+      gchar *prgname;
 
-          prgname = g_path_get_basename (argv[0]);
-          g_set_prgname (prgname);
-          g_free (prgname);
-        }
+      prgname = g_path_get_basename (argv[0]);
+      g_set_prgname (prgname);
+      g_free (prgname);
     }
 
   if (!G_APPLICATION_GET_CLASS (application)


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