libgnomekbd r354 - in trunk: . libgnomekbd



Author: svu
Date: Mon Oct 27 14:52:02 2008
New Revision: 354
URL: http://svn.gnome.org/viewvc/libgnomekbd?rev=354&view=rev

Log:
fix crash in broken X env, b.g.o#553915

Modified:
   trunk/ChangeLog
   trunk/libgnomekbd/gkbd-indicator.c

Modified: trunk/libgnomekbd/gkbd-indicator.c
==============================================================================
--- trunk/libgnomekbd/gkbd-indicator.c	(original)
+++ trunk/libgnomekbd/gkbd-indicator.c	Mon Oct 27 14:52:02 2008
@@ -135,7 +135,12 @@
 	GtkNotebook *notebook = GTK_NOTEBOOK (gki);
 
 	for (grp = 0; grp < total_groups; grp++) {
-		GtkWidget *page, *decorated_page;
+		GtkWidget *page, *decorated_page = NULL;
+		gchar *full_group_name =
+		    (grp <
+		     g_strv_length (globals.
+				    full_group_names)) ?
+		    globals.full_group_names[grp] : "?";
 		page = gkbd_indicator_prepare_drawing (gki, grp);
 
 		if (page == NULL)
@@ -144,7 +149,7 @@
 		decorated_page =
 		    gkbd_indicator_plugin_manager_decorate_widget
 		    (&globals.plugin_manager, page, grp,
-		     globals.full_group_names[grp], &globals.kbd_cfg);
+		     full_group_name, &globals.kbd_cfg);
 
 		page = decorated_page == NULL ? page : decorated_page;
 
@@ -257,39 +262,46 @@
 			    g_hash_table_new_full (g_str_hash, g_str_equal,
 						   g_free, NULL);
 
-		if (xkl_engine_get_features (globals.engine) &
-		    XKLF_MULTIPLE_LAYOUTS_SUPPORTED) {
-			char *full_layout_name =
-			    (char *) g_slist_nth_data (globals.kbd_cfg.
-						       layouts_variants,
-						       group);
-			char *variant_name;
-			if (!gkbd_keyboard_config_split_items
-			    (full_layout_name, &layout_name,
-			     &variant_name))
-				/* just in case */
-				layout_name = full_layout_name;
-
-			/* make it freeable */
-			layout_name = g_strdup (layout_name);
-
-			if (globals.short_group_names != NULL) {
-				char *short_group_name =
-				    globals.short_group_names[group];
-				if (short_group_name != NULL
-				    && *short_group_name != '\0') {
-					/* drop the long name */
-					g_free (layout_name);
-					layout_name =
-					    g_strdup (short_group_name);
+
+		if (group < g_strv_length (globals.short_group_names)) {
+			if (xkl_engine_get_features (globals.engine) &
+			    XKLF_MULTIPLE_LAYOUTS_SUPPORTED) {
+				char *full_layout_name = (char *)
+				    g_slist_nth_data (globals.kbd_cfg.
+						      layouts_variants,
+						      group);
+				char *variant_name;
+				if (!gkbd_keyboard_config_split_items
+				    (full_layout_name, &layout_name,
+				     &variant_name))
+					/* just in case */
+					layout_name = full_layout_name;
+
+				/* make it freeable */
+				layout_name = g_strdup (layout_name);
+
+				if (globals.short_group_names != NULL) {
+					char *short_group_name =
+					    globals.short_group_names
+					    [group];
+					if (short_group_name != NULL
+					    && *short_group_name != '\0') {
+						/* drop the long name */
+						g_free (layout_name);
+						layout_name =
+						    g_strdup
+						    (short_group_name);
+					}
 				}
+			} else {
+				layout_name =
+				    g_strdup (globals.full_group_names
+					      [group]);
 			}
-		} else
-			layout_name =
-			    g_strdup (globals.full_group_names[group]);
+		}
 
 		if (layout_name == NULL)
-			layout_name = g_strdup ("?");
+			layout_name = g_strdup ("??");
 
 		/* Process layouts with repeating description */
 		ppln = &prev_layout_name;
@@ -347,7 +359,8 @@
 {
 	XklState *state = xkl_engine_get_current_state (globals.engine);
 	gchar *buf;
-	if (state == NULL || state->group < 0)
+	if (state == NULL || state->group < 0
+	    || state->group >= g_strv_length (globals.full_group_names))
 		return;
 
 	buf = g_strdup_printf (globals.tooltips_format,
@@ -401,12 +414,9 @@
 					     &globals.kbd_cfg);
 	gkbd_indicator_config_activate (&globals.ind_cfg);
 
-	gkbd_indicator_plugin_manager_toggle_plugins (&globals.
-						      plugin_manager,
-						      &globals.
-						      plugin_container,
-						      globals.ind_cfg.
-						      enabled_plugins);
+	gkbd_indicator_plugin_manager_toggle_plugins
+	    (&globals.plugin_manager, &globals.plugin_container,
+	     globals.ind_cfg.enabled_plugins);
 
 	ForAllIndicators () {
 		gkbd_indicator_reinit_ui (gki);
@@ -465,8 +475,8 @@
 	}
 
 	gkbd_indicator_load_group_names ((const gchar **) xklrec->layouts,
-					 (const gchar **) xklrec->
-					 variants);
+					 (const gchar **)
+					 xklrec->variants);
 
 	ForAllIndicators () {
 		gkbd_indicator_reinit_ui (gki);
@@ -664,8 +674,8 @@
 	gkbd_desktop_config_stop_listen (&globals.cfg);
 	gkbd_indicator_config_stop_listen (&globals.ind_cfg);
 
-	gkbd_indicator_plugin_manager_term_initialized_plugins (&globals.
-								plugin_manager);
+	gkbd_indicator_plugin_manager_term_initialized_plugins
+	    (&globals.plugin_manager);
 	gkbd_indicator_plugin_manager_term (&globals.plugin_manager);
 
 	gkbd_indicator_config_term (&globals.ind_cfg);
@@ -756,18 +766,14 @@
 	gkbd_indicator_config_activate (&globals.ind_cfg);
 
 	gkbd_indicator_load_group_names ((const gchar **) xklrec->layouts,
-					 (const gchar **) xklrec->
-					 variants);
+					 (const gchar **)
+					 xklrec->variants);
 	g_object_unref (G_OBJECT (xklrec));
 
 	gkbd_indicator_plugin_manager_init (&globals.plugin_manager);
-	gkbd_indicator_plugin_manager_init_enabled_plugins (&globals.
-							    plugin_manager,
-							    &globals.
-							    plugin_container,
-							    globals.
-							    ind_cfg.
-							    enabled_plugins);
+	gkbd_indicator_plugin_manager_init_enabled_plugins
+	    (&globals.plugin_manager, &globals.plugin_container,
+	     globals.ind_cfg.enabled_plugins);
 	gkbd_desktop_config_start_listen (&globals.cfg,
 					  (GConfClientNotifyFunc)
 					  gkbd_indicator_cfg_changed,
@@ -821,10 +827,9 @@
 {
 	if (!globals.ind_cfg.show_flags)
 		return NULL;
-	return gkbd_indicator_config_get_images_file (&globals.
-						      ind_cfg,
-						      &globals.
-						      kbd_cfg, group);
+	return gkbd_indicator_config_get_images_file (&globals.ind_cfg,
+						      &globals.kbd_cfg,
+						      group);
 }
 
 gdouble



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