Simplify and improve qe_check_buffer_file

* pass `QEmacsState` to key grab functions
* clear `grab_key_opaque` when freeing windows, buffers, mode_data
* add checks on window and buffer pointers in key grab functions
* this should fix a crash bug when deleting unsynched buffers from bufed
* fix `reload_buffer` to update buffer `file_size` and `mtime` fields
* check buffer file before invoking commands that modify the buffer
* check buffer file after command that changes the current window
  or the current window's buffer
This commit is contained in:
Charlie Gordon 2026-06-23 16:24:02 +02:00
commit 6fb16e1cc2
8 changed files with 88 additions and 71 deletions

View file

@ -1368,7 +1368,7 @@ static void shell_display_hook(EditState *e)
}
}
static void shell_key(void *opaque, int key)
static void shell_key(QEmacsState *qs, void *opaque, int key)
{
ShellState *s = opaque;
char buf[10];
@ -1379,8 +1379,8 @@ static void shell_key(void *opaque, int key)
return;
if (key == KEY_CTRL('o') && s->last_key_grabbed == KEY_CTRL(' ')) {
qe_ungrab_keys(s->base.qs);
qe_unget_key(s->base.qs, key);
qe_ungrab_keys(qs);
qe_unget_key(qs, key);
s->last_key_grabbed = key;
return;
}
@ -2878,7 +2878,6 @@ static EditBuffer *try_show_buffer(EditState **sp, const char *bufname)
e = eb_find_window(b, NULL);
if (e) {
qs->active_window = *sp = e;
qe_check_buffer_file(e->b, CBF_CHECK);
} else {
switch_to_buffer(s, b);
}