Mercurial > geeqie
changeset 523:0717bcc4f2b7
Handle the case of reduction of the number of view directory types.
Previously it was leading to a segfault.
author | zas_ |
---|---|
date | Fri, 25 Apr 2008 08:07:22 +0000 |
parents | fd4208f8b5f3 |
children | 7659ccaf2a74 |
files | src/layout.c src/layout_util.c src/view_dir.c src/view_dir.h |
diffstat | 4 files changed, 7 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/layout.c Thu Apr 24 20:29:09 2008 +0000 +++ b/src/layout.c Fri Apr 25 08:07:22 2008 +0000 @@ -1913,7 +1913,7 @@ layout_config_parse(options->layout.style, options->layout.order, &lw->dir_location, &lw->file_location, &lw->image_location); - lw->dir_view_type = options->layout.dir_view_type; + lw->dir_view_type = CLAMP(options->layout.dir_view_type, 0, VIEW_DIR_TYPES_COUNT - 1); lw->icon_view = options->layout.view_as_icons; /* divider positions */
--- a/src/layout_util.c Thu Apr 24 20:29:09 2008 +0000 +++ b/src/layout_util.c Fri Apr 25 08:07:22 2008 +0000 @@ -1414,7 +1414,7 @@ menu_split_radio_entries, G_N_ELEMENTS(menu_split_radio_entries), 0, G_CALLBACK(layout_menu_split_cb), lw); gtk_action_group_add_radio_actions(lw->action_group, - menu_view_dir_radio_entries, G_N_ELEMENTS(menu_view_dir_radio_entries), + menu_view_dir_radio_entries, VIEW_DIR_TYPES_COUNT, 0, G_CALLBACK(layout_menu_view_dir_as_cb), lw); lw->ui_manager = gtk_ui_manager_new();
--- a/src/view_dir.c Thu Apr 24 20:29:09 2008 +0000 +++ b/src/view_dir.c Fri Apr 25 08:07:22 2008 +0000 @@ -58,6 +58,8 @@ ViewDir *vd_new(DirViewType type, const gchar *path) { + g_assert(VIEW_DIR_TYPES_COUNT <= G_N_ELEMENTS(menu_view_dir_radio_entries)); + ViewDir *vd = g_new0(ViewDir, 1); vd->path = NULL; @@ -618,7 +620,7 @@ submenu = gtk_menu_new(); gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); - for (i = 0; i < G_N_ELEMENTS(menu_view_dir_radio_entries); i++) + for (i = 0; i < VIEW_DIR_TYPES_COUNT; i++) { item = menu_item_add_check(submenu, _(menu_view_dir_radio_entries[i].label), (vd->type == menu_view_dir_radio_entries[i].value),
--- a/src/view_dir.h Thu Apr 24 20:29:09 2008 +0000 +++ b/src/view_dir.h Fri Apr 25 08:07:22 2008 +0000 @@ -20,7 +20,8 @@ DIR_COLUMN_COUNT }; -extern GtkRadioActionEntry menu_view_dir_radio_entries[2]; +#define VIEW_DIR_TYPES_COUNT 1 +extern GtkRadioActionEntry menu_view_dir_radio_entries[VIEW_DIR_TYPES_COUNT]; ViewDir *vd_new(DirViewType type, const gchar *path);