From c32c4b7b41dcf0e170266f819b6a839fa4eac56d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Fri, 29 Apr 2016 08:39:24 +0200 Subject: vis: do not crash when processing :-commands and no window is active This is needed to make the vis.event.start Lua callback useful, setting global options should be possible even if no windows exist yet. The :set command options should probably be cleaned up further, some of them apply only to the currently active window while others have a global effect. --- vis.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'vis.c') diff --git a/vis.c b/vis.c index b22ad41..1397263 100644 --- a/vis.c +++ b/vis.c @@ -286,7 +286,7 @@ bool vis_window_new(Vis *vis, const char *filename) { } bool vis_window_closable(Win *win) { - if (!text_modified(win->file->text)) + if (!win || !text_modified(win->file->text)) return true; return win->file->refcount > 1; } @@ -321,6 +321,8 @@ void vis_window_swap(Win *a, Win *b) { } void vis_window_close(Win *win) { + if (!win) + return; Vis *vis = win->vis; if (!win->file->internal && vis->event && vis->event->win_close) vis->event->win_close(vis, win); -- cgit v1.2.3