gnome-session r4712 - in trunk: . gnome-session



Author: lucasr
Date: Sat May 31 20:40:25 2008
New Revision: 4712
URL: http://svn.gnome.org/viewvc/gnome-session?rev=4712&view=rev

Log:
2008-05-31  Lucas Rocha  <lucasr gnome org>

	Fix crash when appending resumed apps from legacy session file.
	#532075, Ed Catmur. Patch by Ed Catmur.

	* gnome-session/app-resumed.c (get_basename): implement get_basename
	by returning the program name for now. This will probably need to be
	changed in the future with the new session saving implementation based
	on desktop files.
	* gnome-session/app.c (get_basename, gsm_app_get_basename,
	gsm_app_class_init): turn gsm_app_get_basename into an overridable
	method so that we can re-implement it on different types of apps.
	* gnome-session/session.c (append_app): check if basename is NULL
	before checking if app has been registered earlier.


Modified:
   trunk/ChangeLog
   trunk/gnome-session/app-resumed.c
   trunk/gnome-session/app.c
   trunk/gnome-session/app.h
   trunk/gnome-session/session.c

Modified: trunk/gnome-session/app-resumed.c
==============================================================================
--- trunk/gnome-session/app-resumed.c	(original)
+++ trunk/gnome-session/app-resumed.c	Sat May 31 20:40:25 2008
@@ -25,7 +25,8 @@
 
 #include "app-resumed.h"
 
-static pid_t launch (GsmApp *app, GError **error);
+static const char *get_basename (GsmApp *app);
+static pid_t       launch       (GsmApp *app, GError **error);
 
 G_DEFINE_TYPE (GsmAppResumed, gsm_app_resumed, GSM_TYPE_APP)
 
@@ -40,6 +41,7 @@
 {
   GsmAppClass *app_class = GSM_APP_CLASS (klass);
 
+  app_class->get_basename = get_basename;
   app_class->launch = launch;
 }
 
@@ -162,6 +164,12 @@
 }
 #endif
 
+static const char *
+get_basename (GsmApp *app)
+{
+  return GSM_APP_RESUMED (app)->program;
+}
+
 static pid_t
 launch (GsmApp *app, GError **err)
 {

Modified: trunk/gnome-session/app.c
==============================================================================
--- trunk/gnome-session/app.c	(original)
+++ trunk/gnome-session/app.c	Sat May 31 20:40:25 2008
@@ -50,7 +50,8 @@
 			  GValue *value, GParamSpec *pspec);
 static void dispose      (GObject *object);
 
-static pid_t launch (GsmApp *app, GError **err);
+static const char *get_basename (GsmApp *app);
+static pid_t       launch       (GsmApp *app, GError **err);
 
 G_DEFINE_TYPE (GsmApp, gsm_app, G_TYPE_OBJECT)
 
@@ -69,6 +70,7 @@
   object_class->get_property = get_property;
   object_class->dispose = dispose;
 
+  app_class->get_basename = get_basename;
   app_class->launch = launch;
 
   g_object_class_install_property (object_class,
@@ -220,16 +222,21 @@
  * gsm_app_get_basename:
  * @app: a %GsmApp
  *
- * Returns the basename of the path to @app's desktop file (if any).
+ * Returns an identifying name for @app, e.g. the basename of the path to
+ * @app's desktop file (if any).
  *
- * Return value: the basename of the path to @app's desktop file.
+ * Return value: an identifying name for @app, or %NULL.
  **/
 const char *
 gsm_app_get_basename (GsmApp *app)
 {
-  const char *location, *slash;
+  return GSM_APP_GET_CLASS (app)->get_basename (app);
+}
 
-  g_return_val_if_fail (GSM_IS_APP (app), NULL);
+static const char *
+get_basename (GsmApp *app)
+{
+  const char *location, *slash;
 
   if (!app->desktop_file)
     return NULL;

Modified: trunk/gnome-session/app.h
==============================================================================
--- trunk/gnome-session/app.h	(original)
+++ trunk/gnome-session/app.h	Sat May 31 20:40:25 2008
@@ -41,13 +41,14 @@
   GObjectClass parent_class;
 
   /* signals */
-  void     (*exited)      (GsmApp *app, int status);
-  void     (*registered)  (GsmApp *app);
+  void        (*exited)       (GsmApp *app, int status);
+  void        (*registered)   (GsmApp *app);
 
   /* virtual methods */
-  gboolean (*is_disabled) (GsmApp *app);
-  pid_t    (*launch)      (GsmApp *app, GError **err);
-  void     (*set_client)  (GsmApp *app, GsmClient *client);
+  const char *(*get_basename) (GsmApp *app);
+  gboolean    (*is_disabled)  (GsmApp *app);
+  pid_t       (*launch)       (GsmApp *app, GError **err);
+  void        (*set_client)   (GsmApp *app, GsmClient *client);
 };
 
 GType            gsm_app_get_type        (void) G_GNUC_CONST;

Modified: trunk/gnome-session/session.c
==============================================================================
--- trunk/gnome-session/session.c	(original)
+++ trunk/gnome-session/session.c	Sat May 31 20:40:25 2008
@@ -173,9 +173,17 @@
 static void
 append_app (GsmSession *session, GsmApp *app)
 {
-  const char *basename = gsm_app_get_basename (app);
-  GsmApp *dup = g_hash_table_lookup (session->apps_by_name, basename);
+  const char *basename;
+  GsmApp *dup;
 
+  basename = gsm_app_get_basename (app);
+  if (basename == NULL)
+    {
+      g_object_unref (app);
+      return;
+    }
+
+  dup = g_hash_table_lookup (session->apps_by_name, basename);
   if (dup)
     {
       /* FIXME */



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