mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Bookmarks: Fix update after move
do_move_bookmark was only updating the selection in the bookmarks manager
window in which the Move button was pressed. Now all windows are updated.
This patch also prevents a crash when the first item that was displayed
in a box was the last child of a folder and was being moved (the comment
removed in this patch was incorrect in assuming that bm->box->next must
be valid because it neglected to account for non-root children).
This change required that I move the definition of struct
hierbox_dialog_list_item from src/bfu/hierbox.c to src/bfu/hierbox.h.
Thanks to Kalle Olavi Niemitalo for finding both the update problem
and the crash.
[ Backported from commit 6f98f5fd96
in
ELinks 0.12.GIT. --KON ]
This commit is contained in:
parent
c7987e331c
commit
f287d5aa31
@ -24,13 +24,6 @@
|
||||
#include "terminal/terminal.h"
|
||||
|
||||
|
||||
struct hierbox_dialog_list_item {
|
||||
LIST_HEAD(struct hierbox_dialog_list_item);
|
||||
|
||||
struct dialog_data *dlg_data;
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
update_hierbox_browser(struct hierbox_browser *browser)
|
||||
{
|
||||
|
@ -50,6 +50,12 @@ struct hierbox_browser {
|
||||
ops, \
|
||||
}
|
||||
|
||||
struct hierbox_dialog_list_item {
|
||||
LIST_HEAD(struct hierbox_dialog_list_item);
|
||||
|
||||
struct dialog_data *dlg_data;
|
||||
};
|
||||
|
||||
void done_listbox_item(struct hierbox_browser *browser, struct listbox_item *box_item);
|
||||
void update_hierbox_browser(struct hierbox_browser *browser);
|
||||
|
||||
|
@ -367,21 +367,25 @@ do_move_bookmark(struct bookmark *dest, struct list_head *destb,
|
||||
foreachsafe (bm, next, *src) {
|
||||
if (bm != dest /* prevent moving a folder into itself */
|
||||
&& bm->box_item->marked && bm != move_cache_root_avoid) {
|
||||
struct hierbox_dialog_list_item *item;
|
||||
|
||||
bm->box_item->marked = 0;
|
||||
|
||||
trigger_event(move_bookmark_event_id, bm,
|
||||
destb ? (struct bookmark *) destb
|
||||
: dest);
|
||||
|
||||
if (box->top == bm->box_item) {
|
||||
/* It's theoretically impossible that bm->next
|
||||
* would be invalid (point to list_head), as it
|
||||
* would be case only when there would be only
|
||||
* one item in the list, and then bm != dest
|
||||
* will save us already. */
|
||||
box->top = bm->box_item->next;
|
||||
}
|
||||
foreach (item, bookmark_browser.dialogs) {
|
||||
struct widget_data *widget_data;
|
||||
struct listbox_data *box2;
|
||||
|
||||
widget_data = item->dlg_data->widgets_data;
|
||||
box2 = get_listbox_widget_data(widget_data);
|
||||
|
||||
if (box2->top == bm->box_item)
|
||||
listbox_sel_move(widget_data, 1);
|
||||
}
|
||||
|
||||
del_from_list(bm->box_item);
|
||||
del_from_list(bm);
|
||||
add_at_pos(destb ? (struct bookmark *) destb
|
||||
@ -423,7 +427,6 @@ push_move_button(struct dialog_data *dlg_data,
|
||||
struct listbox_data *box = get_dlg_listbox_data(dlg_data);
|
||||
struct bookmark *dest = NULL;
|
||||
struct list_head *destb = NULL, *desti = NULL;
|
||||
struct widget_data *widget_data = dlg_data->widgets_data;
|
||||
|
||||
if (!box->sel) return EVENT_PROCESSED; /* nowhere to move to */
|
||||
|
||||
@ -451,7 +454,7 @@ push_move_button(struct dialog_data *dlg_data,
|
||||
#ifdef BOOKMARKS_RESAVE
|
||||
write_bookmarks();
|
||||
#endif
|
||||
display_widget(dlg_data, widget_data);
|
||||
update_hierbox_browser(&bookmark_browser);
|
||||
return EVENT_PROCESSED;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user