Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-09-27 10:05:08 +0300
committerCampbell Barton <campbell@blender.org>2022-09-27 10:14:32 +0300
commitb6a7541f87c5ed07634eb829af3abdb8239aca18 (patch)
treefc8fae83946c733b9fcecbc0509191fbe0a4a325 /source/blender
parent78952518e7c8fbb4a7866004d03f8004703f6934 (diff)
GHOST: exit with an error when GHOST cannot be initialized
When the GHOST back-end Blender was built with isn't supported, Blender would crash on startup without any useful information. This could happen when building X11 only, then running on Wayland. Now show a list of the GHOST back-ends that were attempted and exit with an error code instead of crashing.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/windowmanager/intern/wm_playanim.c8
-rw-r--r--source/blender/windowmanager/intern/wm_window.c7
2 files changed, 15 insertions, 0 deletions
diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c
index bb19ba4748f..bf793ee41a0 100644
--- a/source/blender/windowmanager/intern/wm_playanim.c
+++ b/source/blender/windowmanager/intern/wm_playanim.c
@@ -1539,6 +1539,14 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
GHOST_SetBacktraceHandler((GHOST_TBacktraceFn)BLI_system_backtrace);
g_WS.ghost_system = GHOST_CreateSystem();
+
+ if (UNLIKELY(g_WS.ghost_system == NULL)) {
+ /* GHOST will have reported the back-ends that failed to load. */
+ fprintf(stderr, "GHOST: unable to initialize, exiting!\n");
+ /* This will leak memory, it's preferable to crashing. */
+ exit(1);
+ }
+
GHOST_AddEventConsumer(g_WS.ghost_system, consumer);
playanim_window_open("Blender Animation Player", start_x, start_y, ibuf->x, ibuf->y);
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 89bf2b82426..a4f92da2774 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -1546,6 +1546,13 @@ void wm_ghost_init(bContext *C)
g_system = GHOST_CreateSystem();
+ if (UNLIKELY(g_system == NULL)) {
+ /* GHOST will have reported the back-ends that failed to load. */
+ fprintf(stderr, "GHOST: unable to initialize, exiting!\n");
+ /* This will leak memory, it's preferable to crashing. */
+ exit(1);
+ }
+
GHOST_Debug debug = {0};
if (G.debug & G_DEBUG_GHOST) {
debug.flags |= GHOST_kDebugDefault;