[DMenu] Do not crash when no entry is available.

Issue: #1504
This commit is contained in:
Dave Davenport 2021-10-16 01:39:21 +02:00
parent ec7aa09f0a
commit 06bb72d39b
2 changed files with 10 additions and 4 deletions

View File

@ -545,7 +545,9 @@ static void dmenu_print_results(DmenuModePrivateData *pd, const char *input) {
if (pd->selected_line != UINT32_MAX) {
cmd = cmd_list[pd->selected_line].entry;
}
rofi_output_formatted_line(pd->format, cmd, pd->selected_line, input);
if ( cmd ) {
rofi_output_formatted_line(pd->format, cmd, pd->selected_line, input);
}
}
}

View File

@ -1677,9 +1677,13 @@ static WidgetTriggerActionResult textbox_button_trigger_action(
switch (action) {
case MOUSE_CLICK_DOWN: {
const char *type = rofi_theme_get_string(wid, "action", NULL);
if (type) {
(state->selected_line) =
state->line_map[listview_get_selected(state->list_view)];
if (type ) {
if ( state->list_view) {
(state->selected_line) =
state->line_map[listview_get_selected(state->list_view)];
} else {
(state->selected_line) = UINT32_MAX;
}
guint id = key_binding_get_action_from_name(type);
if (id != UINT32_MAX) {
rofi_view_trigger_global_action(id);