mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Simplify query_delete_selected_item
Check whether the item can be deleted before allocating the context so as to save a free in the case that the item cannot be deleted.
This commit is contained in:
parent
e9799a2265
commit
b97508e48a
@ -733,20 +733,19 @@ query_delete_selected_item(void *context_)
|
|||||||
|
|
||||||
assert(item);
|
assert(item);
|
||||||
|
|
||||||
context = init_listbox_context(box, term, item, NULL);
|
|
||||||
if (!context) return EVENT_PROCESSED;
|
|
||||||
|
|
||||||
context->widget_data = oldcontext->widget_data;
|
|
||||||
|
|
||||||
delete = ops->can_delete(item)
|
delete = ops->can_delete(item)
|
||||||
? DELETE_LOCKED : DELETE_IMPOSSIBLE;
|
? DELETE_LOCKED : DELETE_IMPOSSIBLE;
|
||||||
|
|
||||||
if (delete == DELETE_IMPOSSIBLE || ops->is_used(item)) {
|
if (delete == DELETE_IMPOSSIBLE || ops->is_used(item)) {
|
||||||
print_delete_error(item, term, ops, delete);
|
print_delete_error(item, term, ops, delete);
|
||||||
mem_free(context);
|
|
||||||
return EVENT_PROCESSED;
|
return EVENT_PROCESSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
context = init_listbox_context(box, term, item, NULL);
|
||||||
|
if (!context) return EVENT_PROCESSED;
|
||||||
|
|
||||||
|
context->widget_data = oldcontext->widget_data;
|
||||||
|
|
||||||
text = ops->get_text(item, term);
|
text = ops->get_text(item, term);
|
||||||
if (!text) {
|
if (!text) {
|
||||||
mem_free(context);
|
mem_free(context);
|
||||||
|
Loading…
Reference in New Issue
Block a user