[Xfce4-commits] <xfce4-xkb-plugin:4.10_panel_support> Handle malformed .rc file more gracefully

Igor Slepchin noreply at xfce.org
Wed Apr 3 01:44:05 CEST 2013


Updating branch refs/heads/4.10_panel_support
         to 35991f4e1a0507603f11d5b4fea09dae683b8a02 (commit)
       from 213590fc41e272541f057b13a67fb1850877b145 (commit)

commit 35991f4e1a0507603f11d5b4fea09dae683b8a02
Author: Igor Slepchin <igor.slepchin at gmail.com>
Date:   Mon Apr 1 17:49:02 2013 -0400

    Handle malformed .rc file more gracefully
    
    We will try to load xkl config first and use the current xkl
    config for any .rc settings we fail to load.
    This should fix the crash when loading the "old" xkb-plugin
    with the .rc file created by the plugin from the git master.

 panel-plugin/xfce4-xkb-plugin.c |   34 +++++++++++++++++++---------------
 panel-plugin/xkb-config.c       |    2 ++
 2 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/panel-plugin/xfce4-xkb-plugin.c b/panel-plugin/xfce4-xkb-plugin.c
index e1c8439..b47269b 100644
--- a/panel-plugin/xfce4-xkb-plugin.c
+++ b/panel-plugin/xfce4-xkb-plugin.c
@@ -172,12 +172,7 @@ xkb_new (XfcePanelPlugin *plugin)
     xkb->settings = g_new0 (t_xkb_settings, 1);
     xkb->plugin = plugin;
 
-    filename = xfce_panel_plugin_lookup_rc_file (plugin);
-    if ((!filename) || (!xkb_load_config (xkb, filename)))
-    {
-        xkb_load_default (xkb);
-    }
-    g_free (filename);
+    xkb_load_default (xkb);
 
     xkb->btn = gtk_button_new ();
     gtk_button_set_relief (GTK_BUTTON (xkb->btn), GTK_RELIEF_NONE);
@@ -214,6 +209,15 @@ xkb_new (XfcePanelPlugin *plugin)
         xkb_initialize_menu (xkb);
     }
 
+    filename = xfce_panel_plugin_lookup_rc_file (plugin);
+    if (xkb_load_config (xkb, filename))
+    {
+        xkb_config_update_settings (xkb->settings);
+    }
+    g_free (filename);
+
+
+
     wnck_screen = wnck_screen_get_default ();
     g_signal_connect (G_OBJECT (wnck_screen), "active-window-changed",
             G_CALLBACK (xkb_plugin_active_window_changed), xkb);
@@ -294,6 +298,9 @@ static gboolean
 xkb_load_config (t_xkb *xkb, const gchar *filename)
 {
     XfceRc* rcfile;
+
+    TRACE ("rc filename: %s", filename);
+
     if ((rcfile = xfce_rc_simple_open (filename, TRUE)))
     {
         xfce_rc_set_group (rcfile, NULL);
@@ -309,15 +316,12 @@ xkb_load_config (t_xkb *xkb, const gchar *filename)
 
         xkb->settings->never_modify_config = xfce_rc_read_bool_entry (rcfile, "never_modify_config", FALSE);
 
-        if (xkb->settings->kbd_config == NULL)
-        {
-            xkb->settings->kbd_config = g_new0 (t_xkb_kbd_config, 1);
-        }
-        xkb->settings->kbd_config->model = g_strdup (xfce_rc_read_entry (rcfile, "model", NULL));
-        xkb->settings->kbd_config->layouts = g_strdup (xfce_rc_read_entry (rcfile, "layouts", NULL));
-        xkb->settings->kbd_config->variants = g_strdup (xfce_rc_read_entry (rcfile, "variants", NULL));
-        xkb->settings->kbd_config->toggle_option = g_strdup (xfce_rc_read_entry (rcfile, "toggle_option", NULL));
-        xkb->settings->kbd_config->compose_key_position = g_strdup (xfce_rc_read_entry (rcfile, "compose_key_position", NULL));
+        g_assert (xkb->settings->kbd_config != NULL);
+        xkb->settings->kbd_config->model = g_strdup (xfce_rc_read_entry (rcfile, "model", xkb->settings->kbd_config->model));
+        xkb->settings->kbd_config->layouts = g_strdup (xfce_rc_read_entry (rcfile, "layouts", xkb->settings->kbd_config->layouts));
+        xkb->settings->kbd_config->variants = g_strdup (xfce_rc_read_entry (rcfile, "variants", xkb->settings->kbd_config->variants));
+        xkb->settings->kbd_config->toggle_option = g_strdup (xfce_rc_read_entry (rcfile, "toggle_option", xkb->settings->kbd_config->toggle_option));
+        xkb->settings->kbd_config->compose_key_position = g_strdup (xfce_rc_read_entry (rcfile, "compose_key_position", xkb->settings->kbd_config->compose_key_position));
 
         xfce_rc_close (rcfile);
 
diff --git a/panel-plugin/xkb-config.c b/panel-plugin/xkb-config.c
index 3e76039..88c7af5 100644
--- a/panel-plugin/xkb-config.c
+++ b/panel-plugin/xkb-config.c
@@ -406,6 +406,8 @@ xkb_config_update_settings (t_xkb_settings *settings)
         if (!xkl_config_rec_activate (config->config_rec, config->engine))
         {
             DBG ("ERROR: can't activate xkl config: [%s]", xkl_get_last_error());
+            XKB_DEBUG_CONFIG_REC (config->config_rec, "activated");
+            return FALSE;
             // FIXME: we should probably try to reload from xkl config here
         }
         ignore_xkl_config_change = FALSE;


More information about the Xfce4-commits mailing list