From acbe76ca6d576c397112c08b86bb9c301102f4ab Mon Sep 17 00:00:00 2001 From: infirit Date: Fri, 7 Nov 2014 12:59:59 +0100 Subject: gsm: Do not assume XSMP clients set the SmProgram property Since setting some properties can be skipped, there is no guarantee that SmProgram is set. Based on gnome-session commit: 35a9945ae1339297de2e0eeff543e876186dea6e From: Vincent Untz Gnome bug: https://bugzilla.gnome.org/show_bug.cgi?id=590828 --- mate-session/gsm-xsmp-client.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'mate-session') diff --git a/mate-session/gsm-xsmp-client.c b/mate-session/gsm-xsmp-client.c index f8b78c2..759e2ab 100644 --- a/mate-session/gsm-xsmp-client.c +++ b/mate-session/gsm-xsmp-client.c @@ -524,6 +524,11 @@ get_desktop_file_path (GsmXSMPClient *client) /* If we can't get desktop file from GsmDesktopFile then we * try to find the desktop file from its program name */ prop = find_property (client, SmProgram, NULL); + + if (!prop) { + goto out; + } + program_name = prop->vals[0].value; dirs = gsm_util_get_autostart_dirs (); @@ -551,7 +556,16 @@ set_desktop_file_keys_from_client (GsmClient *client, char *comment; prop = find_property (GSM_XSMP_CLIENT (client), SmProgram, NULL); - name = g_strdup (prop->vals[0].value); + + if (prop) { + name = g_strdup (prop->vals[0].value); + } else { + /* It'd be really surprising to reach this code: if we're here, + * then the XSMP client already has set several XSMP + * properties. But it could still be that SmProgram is not set. + */ + name = g_strdup (_("Remembered Application")); + } comment = g_strdup_printf ("Client %s which was automatically saved", gsm_client_peek_startup_id (client)); @@ -639,6 +653,7 @@ xsmp_save (GsmClient *client, desktop_file_path = get_desktop_file_path (GSM_XSMP_CLIENT (client)); + /* this can accept desktop_file_path == NULL */ keyfile = create_client_key_file (client, desktop_file_path, &local_error); @@ -778,10 +793,12 @@ static char * xsmp_get_app_name (GsmClient *client) { SmProp *prop; - char *name; + char *name = NULL; prop = find_property (GSM_XSMP_CLIENT (client), SmProgram, NULL); - name = prop_to_command (prop); + if (prop) { + name = prop_to_command (prop); + } return name; } -- cgit v1.2.1