fixed crash with unmapped buttons
authorJavier S. Pedro <maemo@javispedro.com>
Wed, 26 Aug 2009 23:00:26 +0000 (01:00 +0200)
committerJavier S. Pedro <maemo@javispedro.com>
Wed, 26 Aug 2009 23:00:26 +0000 (01:00 +0200)
gui/controls.c
gui/plugin.c
platform/hgw.cpp

index 7970c97..0dedcc9 100644 (file)
@@ -79,7 +79,6 @@ static void show_widgets()
        switch (gtk_combo_box_get_active(combo)) {
                case 0:
                        gtk_widget_show_all(GTK_WIDGET(none_label));
-                       g_debug("Showing label\n");
                        break;
                case 1:
                        gtk_widget_show_all(GTK_WIDGET(keys_scroll));
@@ -191,7 +190,8 @@ cb_key_cleared(GtkCellRendererText *cell, const char *path_string,
                -1);
 
        g_debug("Clearing scancode for button %s\n", button_entry->name);
-       gconf_client_unset(gcc, button_entry->gconf_key, NULL);
+       gconf_client_set_int(gcc, button_entry->gconf_key, 0, NULL);
+               // prefer 0 value over unset key.
 
        button_entry->scancode = 0;
 }
index 79e0fe7..61b1ec5 100644 (file)
@@ -70,8 +70,11 @@ static GtkComboBox* speedhacks_combo;
 
 static void set_rom(const char * rom_file)
 {
-       if (!rom_file) return;
        if (current_rom_file) g_free(current_rom_file);
+       if (!rom_file) {
+               current_rom_file = NULL;
+               return;
+       }
 
        gchar * utf8_filename = g_filename_display_name(rom_file);
 
@@ -265,8 +268,6 @@ static void write_config(void)
 
        if (current_rom_file) {
                gconf_client_set_string(gcc, kGConfRomFile, current_rom_file, NULL);
-       } else {
-               gconf_client_unset(gcc, kGConfRomFile, NULL);
        }
 
        controls_setup();
index 8a4e072..d4273ee 100644 (file)
@@ -207,8 +207,7 @@ static void parseGConfKeyMappings()
        int i, scancode;
        for (i = 0; buttons[i].gconf_key; i++) {
                if (hgw_conf_request_int(hgw, buttons[i].gconf_key, &scancode) == HGW_ERR_NONE) {
-                       if (scancode < 0) scancode = 0;
-                       else if (scancode > 255) scancode = 0;
+                       if (scancode <= 0 || scancode > 255) continue;
 
                        if (buttons[i].is_action) {
                                Config.action[scancode] = buttons[i].mask;