Skip to content

Commit 8ca65ef

Browse files
committed
Merge Sherlock's 'Bug 799654' into stable.
2 parents ea17983 + 28aaf38 commit 8ca65ef

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

gnucash/gnome-utils/gnc-plugin-file-history.c

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,6 @@ gnc_history_update_action (GncMainWindow *window,
407407
GncMenuModelSearch *gsm = g_new0 (GncMenuModelSearch, 1);
408408
gchar *action_name;
409409
gint limit;
410-
gboolean add_item = FALSE;
411-
gint pos;
412410

413411
ENTER("window %p, index %d, filename %s", window, index,
414412
filename ? filename : "(null)");
@@ -418,9 +416,12 @@ gnc_history_update_action (GncMainWindow *window,
418416
gsm->search_action_label = NULL;
419417
gsm->search_action_name = action_name;
420418

421-
if (!gnc_menubar_model_find_item (gnc_main_window_get_menu_model(window), gsm)) // could not find action_name
419+
if (gnc_menubar_model_find_item (gnc_main_window_get_menu_model(window), gsm))
420+
{
421+
g_menu_remove (G_MENU(gsm->model), gsm->index);
422+
}
423+
else // could not find action_name
422424
{
423-
add_item = TRUE;
424425
gsm->search_action_name = "FilePlaceholder6"; // placeholder
425426

426427
if (!gnc_menubar_model_find_item (gnc_main_window_get_menu_model(window), gsm))
@@ -430,16 +431,12 @@ gnc_history_update_action (GncMainWindow *window,
430431
g_free (action_name);
431432
return;
432433
}
433-
else
434-
pos = gsm->index + index;
434+
gsm->index += index;
435435
}
436-
else
437-
pos = gsm->index;
438436

439-
limit = gnc_prefs_get_int (GNC_PREFS_GROUP_HISTORY,
440-
GNC_PREF_HISTORY_MAXFILES);
437+
limit = gnc_prefs_get_int (GNC_PREFS_GROUP_HISTORY, GNC_PREF_HISTORY_MAXFILES);
441438

442-
if (filename && (strlen(filename) > 0) && (index < limit))
439+
if (filename && *filename && index < limit)
443440
{
444441
GMenuItem *item;
445442
gchar *label_name = gnc_history_generate_label (index, filename);
@@ -448,13 +445,8 @@ gnc_history_update_action (GncMainWindow *window,
448445
action_name, NULL);
449446

450447
item = g_menu_item_new (label_name, full_action_name);
451-
452448
g_menu_item_set_attribute (item, GNC_MENU_ATTRIBUTE_TOOLTIP, "s", tooltip);
453-
454-
if (!add_item)
455-
g_menu_remove (G_MENU(gsm->model), pos);
456-
457-
g_menu_insert_item (G_MENU(gsm->model), pos, item);
449+
g_menu_insert_item (G_MENU(gsm->model), gsm->index, item);
458450

459451
g_free (full_action_name);
460452
g_free (label_name);

0 commit comments

Comments
 (0)