gnome-session r4983 - in trunk: . gnome-session



Author: mccann
Date: Thu Aug 21 21:27:15 2008
New Revision: 4983
URL: http://svn.gnome.org/viewvc/gnome-session?rev=4983&view=rev

Log:
2008-08-21  William Jon McCann  <jmccann redhat com>

	* gnome-session/gsm-autostart-app.c (gsm_autostart_app_restart):
	* gnome-session/gsm-manager.c (_app_has_startup_id),
	(find_app_for_startup_id), (_disconnect_client):
	Don't return an error if we can't stop an app that we want
	to restart.  It may be stopped.  Also try to find the
	app based on the startup ID first if we have one.
	Probably fixes #548710



Modified:
   trunk/ChangeLog
   trunk/gnome-session/gsm-autostart-app.c
   trunk/gnome-session/gsm-manager.c

Modified: trunk/gnome-session/gsm-autostart-app.c
==============================================================================
--- trunk/gnome-session/gsm-autostart-app.c	(original)
+++ trunk/gnome-session/gsm-autostart-app.c	Thu Aug 21 21:27:15 2008
@@ -935,11 +935,12 @@
         GError  *local_error;
         gboolean res;
 
+        /* ignore stop errors - it is fine if it is already stopped */
         local_error = NULL;
         res = gsm_app_stop (app, &local_error);
         if (! res) {
-                g_propagate_error (error, local_error);
-                return FALSE;
+                g_debug ("GsmAutostartApp: Couldn't stop app: %s", local_error->message);
+                g_error_free (local_error);
         }
 
         res = gsm_app_start (app, &local_error);

Modified: trunk/gnome-session/gsm-manager.c
==============================================================================
--- trunk/gnome-session/gsm-manager.c	(original)
+++ trunk/gnome-session/gsm-manager.c	Thu Aug 21 21:27:15 2008
@@ -1107,6 +1107,58 @@
         return matches;
 }
 
+static gboolean
+_app_has_startup_id (const char *id,
+                     GsmApp     *app,
+                     const char *startup_id_a)
+{
+        const char *startup_id_b;
+
+        startup_id_b = gsm_app_peek_startup_id (app);
+
+        if (IS_STRING_EMPTY (startup_id_b)) {
+                return FALSE;
+        }
+
+        return (strcmp (startup_id_a, startup_id_b) == 0);
+}
+
+static GsmApp *
+find_app_for_startup_id (GsmManager *manager,
+                        const char *startup_id)
+{
+        GsmApp *found_app;
+        GSList *a;
+
+        found_app = NULL;
+
+        /* If we're starting up the session, try to match the new client
+         * with one pending apps for the current phase. If not, try to match
+         * with any of the autostarted apps. */
+        if (manager->priv->phase < GSM_MANAGER_PHASE_APPLICATION) {
+                for (a = manager->priv->pending_apps; a != NULL; a = a->next) {
+                        GsmApp *app = GSM_APP (a->data);
+
+                        if (strcmp (startup_id, gsm_app_peek_startup_id (app)) == 0) {
+                                found_app = app;
+                                goto out;
+                        }
+                }
+        } else {
+                GsmApp *app;
+
+                app = (GsmApp *)gsm_store_find (manager->priv->apps,
+                                                (GsmStoreFunc)_app_has_startup_id,
+                                                (char *)startup_id);
+                if (app != NULL) {
+                        found_app = app;
+                        goto out;
+                }
+        }
+ out:
+        return found_app;
+}
+
 static void
 _disconnect_client (GsmManager *manager,
                     GsmClient  *client)
@@ -1116,6 +1168,7 @@
         GError               *error;
         gboolean              res;
         const char           *app_id;
+        const char           *startup_id;
         gboolean              app_restart;
         GsmClientRestartStyle client_restart_hint;
 
@@ -1138,16 +1191,26 @@
                                   (GsmStoreFunc)inhibitor_has_client_id,
                                   (gpointer)gsm_client_peek_id (client));
 
-        app_id = gsm_client_peek_app_id (client);
-        if (IS_STRING_EMPTY (app_id)) {
-                g_debug ("GsmManager: no application associated with client, not restarting application");
-                goto out;
+        app = NULL;
+
+        /* first try to match on startup ID */
+        startup_id = gsm_client_peek_startup_id (client);
+        if (! IS_STRING_EMPTY (startup_id)) {
+                app = find_app_for_startup_id (manager, startup_id);
+
+        }
+
+        /* then try to find matching app-id */
+        if (app == NULL) {
+                app_id = gsm_client_peek_app_id (client);
+                if (! IS_STRING_EMPTY (app_id)) {
+                        g_debug ("GsmManager: disconnect for app '%s'", app_id);
+                        app = find_app_for_app_id (manager, app_id);
+                }
         }
 
-        g_debug ("GsmManager: disconnect for app '%s'", app_id);
-        app = find_app_for_app_id (manager, app_id);
         if (app == NULL) {
-                g_debug ("GsmManager: invalid application id, not restarting application");
+                g_debug ("GsmManager: unable to find application for client - not restarting");
                 goto out;
         }
 
@@ -1275,58 +1338,6 @@
                                               &data);
 }
 
-static gboolean
-_app_has_startup_id (const char *id,
-                     GsmApp     *app,
-                     const char *startup_id_a)
-{
-        const char *startup_id_b;
-
-        startup_id_b = gsm_app_peek_startup_id (app);
-
-        if (IS_STRING_EMPTY (startup_id_b)) {
-                return FALSE;
-        }
-
-        return (strcmp (startup_id_a, startup_id_b) == 0);
-}
-
-static GsmApp *
-find_app_for_startup_id (GsmManager *manager,
-                        const char *startup_id)
-{
-        GsmApp *found_app;
-        GSList *a;
-
-        found_app = NULL;
-
-        /* If we're starting up the session, try to match the new client
-         * with one pending apps for the current phase. If not, try to match
-         * with any of the autostarted apps. */
-        if (manager->priv->phase < GSM_MANAGER_PHASE_APPLICATION) {
-                for (a = manager->priv->pending_apps; a != NULL; a = a->next) {
-                        GsmApp *app = GSM_APP (a->data);
-
-                        if (strcmp (startup_id, gsm_app_peek_startup_id (app)) == 0) {
-                                found_app = app;
-                                goto out;
-                        }
-                }
-        } else {
-                GsmApp *app;
-
-                app = (GsmApp *)gsm_store_find (manager->priv->apps,
-                                                (GsmStoreFunc)_app_has_startup_id,
-                                                (char *)startup_id);
-                if (app != NULL) {
-                        found_app = app;
-                        goto out;
-                }
-        }
- out:
-        return found_app;
-}
-
 static void
 bus_name_owner_changed (DBusGProxy  *bus_proxy,
                         const char  *service_name,



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