aboutsummaryrefslogtreecommitdiff
path: root/vis.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-04-29 08:39:24 +0200
committerMarc André Tanner <mat@brain-dump.org>2016-04-29 08:43:58 +0200
commitc32c4b7b41dcf0e170266f819b6a839fa4eac56d (patch)
tree70032de60fc183a4050f3a9322983d3ff0f365a2 /vis.c
parent0ef138085f885d4576a8e53d079e1f00f80799bf (diff)
downloadvis-c32c4b7b41dcf0e170266f819b6a839fa4eac56d.tar.gz
vis-c32c4b7b41dcf0e170266f819b6a839fa4eac56d.tar.xz
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.
Diffstat (limited to 'vis.c')
-rw-r--r--vis.c4
1 files changed, 3 insertions, 1 deletions
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);