Bug#286220: patch for the problem

Gustavo Noronha Silva Gustavo Noronha Silva <kov@debian.org>, 286220@bugs.debian.org
Thu, 03 Feb 2005 14:15:41 -0200


--=-0So3ZDpAkEZKNXr07VZ4
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hey,

Marga, I finally got around to reproducing the problem using a different
X server (xagent, from FreeNX). I believe the attached patch will fix
the segfault, though that boring window will still appear.

Would you test it for us? =)

Thanks!

-- 
kov@debian.org: Gustavo Noronha <http://beterraba.no-ip.org/~kov/>
 Debian: <http://www.debian.org/>  *  <http://www.debian-br.org/>

--=-0So3ZDpAkEZKNXr07VZ4
Content-Disposition: attachment; filename=gswitchit_dont_crash_when_no_xkb_config.diff
Content-Type: text/x-patch; name=gswitchit_dont_crash_when_no_xkb_config.diff; charset=UTF-8
Content-Transfer-Encoding: 7bit

--- libgswitchit/gswitchit_config.c~	2004-10-14 15:44:52.000000000 -0300
+++ libgswitchit/gswitchit_config.c	2005-02-04 12:07:50.000000000 -0200
@@ -500,13 +500,19 @@
 	}
 }
 
-static void
+static gboolean
 _GSwitchItXkbConfigSaveParams (GSwitchItXkbConfig * xkbConfig,
 			       GConfChangeSet * cs,
 			       const char *paramNames[])
 {
 	GSList *pl;
 
+	if (!(xkbConfig->model && xkbConfig->layouts && xkbConfig->options))
+	  {
+	    g_warning ("Error getting xkb configuration.\n");
+	    return 1;
+	  }
+
 	gconf_change_set_set_string (cs, paramNames[0], xkbConfig->model);
 	XklDebug (150, "Saved XKB model: [%s]\n", xkbConfig->model);
 
@@ -526,6 +532,8 @@
 	gconf_change_set_set_list (cs,
 				   paramNames[2],
 				   GCONF_VALUE_STRING, xkbConfig->options);
+
+	return 0;
 }
 
 /**
@@ -670,8 +678,10 @@
 
 	cs = gconf_change_set_new ();
 
-	_GSwitchItXkbConfigSaveParams (xkbConfig, cs,
-				       GSWITCHIT_CONFIG_XKB_SYSBACKUP);
+	/* If 1 is returned no xkb configuration was found, do nothing. */
+	if (!_GSwitchItXkbConfigSaveParams (xkbConfig, cs,
+					    GSWITCHIT_CONFIG_XKB_SYSBACKUP))
+	  return;
 
 	gconf_client_commit_change_set (xkbConfig->confClient, cs, TRUE,
 					&gerror);

--=-0So3ZDpAkEZKNXr07VZ4--