[Geany-devel] load_vte and vc checks

Dimitar Zhekov dimitar.zhekov at xxxxx
Sat Oct 30 09:41:14 UTC 2010


Hi,

While working on unhide prefs, I noticed that different checks are
used to verify if the instance has VTE. In detail:

vte_info has a load_vte field, which corresponds to the "Load virtual
terminal support" setting in the preferences dialog. The most obvious
way to check for VTE, and also completely wrong: the preference can
be (un)checked at any time.

When the preferences are loaded on startup, load_vte is checked, and
if true, VteConfig *vc is allocated. So load_vte && vc != NULL seems
like a better check, but that ignores the -t (--no-terminal) option.

Also on startup, vte_info.have_vte = load_vte && !--no-terminal, and
in vte.c, have_vte = FALSE if VTE can not be loaded. So checking
have_vte is the right thing.

---

Following is a short list of load_vte and vc checks, and load_vte
usage (drop me a note if you need details):

build.c: prepare_run_script(), build_run_cmd(): checks load_vte && vc
run command in vte if one exists and "Execute programs in VTE" is set
Should be has_vte: one can't execute programs in VTE if -t...

keybindings.c: cb_func_select_action(): checks load_vte
on Ctrl+A and if VTE is focused do vte_select_all()
Should be has_vte. If instance is started without vte, and the dialog
preference is set, this crashes.

prefs.c: prefs_init_dialog(), on_prefs_button_clicked(): uses load_vte
set/get the "Load virtual terminal support" check button state - OK.

callbacks.c: on_send_selection_to_vte1_activate(): checks load_vte
handler for Edit -> Commands -> Send selection to terminal
Should be has_vte or no check. The command is removed on startup if
!load_vte, but crashes if -t is specified.

keyfile.c: save_dialog_prefs(): check load_vte && vc
meaning something like "save the preferences if loaded", but ignoring
the case when they can not be changed and so also require no saving.

keyfile.c: load_dialog_prefs(): read and check load_vte
allocate vc and read the other vte settings only if load_vte, but
ignoring -t (the option is local to main.c)

main.c: apply_settings(): checks load_vte
removes the Send selection to terminal command, but see callbacks.c

main.c: load_settings():
vte_info.have_vte = (no_vte) ? FALSE : vte_info.load_vte - OK.

---

What I plan to do:

1. Replace if (load_vte [&& vc != NULL]) with has_vte as needed.

2. Add some "use have_vte not load_vte to check for VTE" comment to
load_vte/have_vte.

3. Make the loading/saving of VTE settings unconditional. Avoiding
load/save economizes only a very short time, and the current checks
whether the settings should be load/saved are wrong anyway.

4. Make vc non-pointer? This way, it'll be clear that vc != NULL is
not a valid check. OTOH, vc-> crashes if vc is not allocated, which
is good, but the current allocation condition is wrong.
That would be about 140 "s/vc->/vc./" changes.

Request for comments.

-- 
E-gards: Jimmy



More information about the Devel mailing list