core: check if a chosen backend is available

Error out instead of segfaulting when the chosen backend is not
available.

Fixes #210

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2019-08-01 21:23:56 +01:00
parent 1f80c8dc16
commit ddde118c69
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
1 changed files with 9 additions and 3 deletions

View File

@ -258,8 +258,8 @@ static bool run_fade(session_t *ps, struct managed_win **_w, long steps) {
}
}
// Note even if opacity == opacity_target here, we still want to run preprocess one
// last time to finish state transition. So return true in that case too.
// Note even if opacity == opacity_target here, we still want to run preprocess
// one last time to finish state transition. So return true in that case too.
return true;
}
@ -723,7 +723,13 @@ static bool initialize_backend(session_t *ps) {
if (ps->o.experimental_backends) {
assert(!ps->backend_data);
// Reinitialize win_data
if (backend_list[ps->o.backend]) {
ps->backend_data = backend_list[ps->o.backend]->init(ps);
} else {
log_error("Backend \"%s\" is not available as part of the "
"experimental backends.",
BACKEND_STRS[ps->o.backend]);
}
if (!ps->backend_data) {
log_fatal("Failed to initialize backend, aborting...");
quit_compton(ps);