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
This commit is contained in:
Lars Uebernickel 2015-02-04 11:01:41 +01:00
parent 62f7ea8191
commit fcb30409ec

View File

@ -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)