[RUN|DRUN] Only initialize file-completer on first use.

This commit is contained in:
Dave Davenport 2021-10-12 13:35:00 +02:00
parent e3860c89e8
commit ccaaaf6a46
2 changed files with 14 additions and 8 deletions

View file

@ -1123,8 +1123,7 @@ static int drun_mode_init(Mode *sw) {
drun_mode_parse_display_format();
get_apps(pd);
pd->completer = create_new_file_browser();
mode_init(pd->completer);
pd->completer = NULL;
return TRUE;
}
static void drun_entry_clear(DRunModeEntry *e) {
@ -1236,6 +1235,8 @@ static ModeMode drun_mode_result(Mode *sw, int mretv, char **input,
g_free(*input);
*input = g_strdup(rmpd->old_completer_input);
rmpd->completer = create_new_file_browser();
mode_init(rmpd->completer);
rmpd->file_complete = TRUE;
}
g_regex_unref(regex);
@ -1258,8 +1259,10 @@ static void drun_mode_destroy(Mode *sw) {
g_free(rmpd->old_completer_input);
g_free(rmpd->old_input);
mode_destroy(rmpd->completer);
g_free(rmpd->completer);
if (rmpd->completer != NULL) {
mode_destroy(rmpd->completer);
g_free(rmpd->completer);
}
g_strfreev(rmpd->current_desktop_list);
g_strfreev(rmpd->show_categories);

View file

@ -382,8 +382,7 @@ static int run_mode_init(Mode *sw) {
RunModePrivateData *pd = g_malloc0(sizeof(*pd));
sw->private_data = (void *)pd;
pd->cmd_list = get_apps(&(pd->cmd_list_length));
pd->completer = create_new_file_browser();
mode_init(pd->completer);
pd->completer = NULL;
}
return TRUE;
@ -400,8 +399,10 @@ static void run_mode_destroy(Mode *sw) {
g_free(rmpd->cmd_list);
g_free(rmpd->old_input);
g_free(rmpd->old_completer_input);
mode_destroy(rmpd->completer);
g_free(rmpd->completer);
if (rmpd->completer != NULL) {
mode_destroy(rmpd->completer);
g_free(rmpd->completer);
}
g_free(rmpd);
sw->private_data = NULL;
}
@ -485,6 +486,8 @@ static ModeMode run_mode_result(Mode *sw, int mretv, char **input,
g_free(*input);
*input = g_strdup(rmpd->old_completer_input);
rmpd->completer = create_new_file_browser();
mode_init(rmpd->completer);
rmpd->file_complete = TRUE;
}
}