diff options
author | Campbell Barton <campbell@blender.org> | 2022-06-10 08:13:25 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-06-10 11:36:10 +0300 |
commit | 2601b9832dc34ff0346bf3c810d6babc2ca22630 (patch) | |
tree | 4afe0890a25289cd3b18574271445aa4ab05a80b | |
parent | eb9fa052a173355475be3d91395ec24fb2b0f865 (diff) |
GHOST: add back-trace handler to the API
Add a back-trace handler to GHOST, so error handlers can include a
back-trace (when supported).
No functional changes.
-rw-r--r-- | intern/ghost/GHOST_C-api.h | 5 | ||||
-rw-r--r-- | intern/ghost/GHOST_ISystem.h | 6 | ||||
-rw-r--r-- | intern/ghost/GHOST_Types.h | 2 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_C-api.cpp | 5 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_ISystem.cpp | 12 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_playanim.c | 3 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_window.c | 3 |
7 files changed, 36 insertions, 0 deletions
diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h index ad19efadba5..388d6eb96d2 100644 --- a/intern/ghost/GHOST_C-api.h +++ b/intern/ghost/GHOST_C-api.h @@ -907,6 +907,11 @@ extern int GHOST_UseNativePixels(void); extern int GHOST_SupportsCursorWarp(void); /** + * Assign the callback which generates a back-trace (may be NULL). + */ +extern void GHOST_SetBacktraceHandler(GHOST_TBacktraceFn backtrace_fn); + +/** * Focus window after opening, or put them in the background. */ extern void GHOST_UseWindowFocus(int use_focus); diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h index 8a4412403f7..436ff7a723e 100644 --- a/intern/ghost/GHOST_ISystem.h +++ b/intern/ghost/GHOST_ISystem.h @@ -133,6 +133,9 @@ class GHOST_ISystem { */ static GHOST_ISystem *getSystem(); + static GHOST_TBacktraceFn getBacktraceFn(); + static void setBacktraceFn(GHOST_TBacktraceFn backtrace_fn); + protected: /** * Constructor. @@ -482,6 +485,9 @@ class GHOST_ISystem { /** The one and only system */ static GHOST_ISystem *m_system; + /** Function to call that sets the back-trace. */ + static GHOST_TBacktraceFn m_backtrace_fn; + #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_ISystem") #endif diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h index 841c0c33ee1..78f2b24ea78 100644 --- a/intern/ghost/GHOST_Types.h +++ b/intern/ghost/GHOST_Types.h @@ -42,6 +42,8 @@ GHOST_DECLARE_HANDLE(GHOST_EventConsumerHandle); GHOST_DECLARE_HANDLE(GHOST_ContextHandle); GHOST_DECLARE_HANDLE(GHOST_XrContextHandle); +typedef void (*GHOST_TBacktraceFn)(void *file_handle); + typedef struct { int flags; } GHOST_GLSettings; diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp index 8dd31a88ad3..3bb7a7618c4 100644 --- a/intern/ghost/intern/GHOST_C-api.cpp +++ b/intern/ghost/intern/GHOST_C-api.cpp @@ -835,6 +835,11 @@ int GHOST_SupportsCursorWarp(void) return system->supportsCursorWarp(); } +void GHOST_SetBacktraceHandler(GHOST_TBacktraceFn backtrace_fn) +{ + GHOST_ISystem::setBacktraceFn(backtrace_fn); +} + void GHOST_UseWindowFocus(int use_focus) { GHOST_ISystem *system = GHOST_ISystem::getSystem(); diff --git a/intern/ghost/intern/GHOST_ISystem.cpp b/intern/ghost/intern/GHOST_ISystem.cpp index 87111306ec7..745d5faeed4 100644 --- a/intern/ghost/intern/GHOST_ISystem.cpp +++ b/intern/ghost/intern/GHOST_ISystem.cpp @@ -31,6 +31,8 @@ GHOST_ISystem *GHOST_ISystem::m_system = nullptr; +GHOST_TBacktraceFn GHOST_ISystem::m_backtrace_fn = nullptr; + GHOST_TSuccess GHOST_ISystem::createSystem() { GHOST_TSuccess success; @@ -89,3 +91,13 @@ GHOST_ISystem *GHOST_ISystem::getSystem() { return m_system; } + +GHOST_TBacktraceFn GHOST_ISystem::getBacktraceFn() +{ + return GHOST_ISystem::m_backtrace_fn; +} + +void GHOST_ISystem::setBacktraceFn(GHOST_TBacktraceFn backtrace_fn) +{ + GHOST_ISystem::m_backtrace_fn = backtrace_fn; +} diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index 7cd54a7e191..b3268cf1701 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -33,6 +33,7 @@ #include "BLI_path_util.h" #include "BLI_rect.h" #include "BLI_string.h" +#include "BLI_system.h" #include "BLI_utildefines.h" #include "IMB_colormanagement.h" @@ -1536,6 +1537,8 @@ static char *wm_main_playanim_intern(int argc, const char **argv) GHOST_EventConsumerHandle consumer = GHOST_CreateEventConsumer(ghost_event_proc, &ps); + GHOST_SetBacktraceHandler((GHOST_TBacktraceFn)BLI_system_backtrace); + g_WS.ghost_system = GHOST_CreateSystem(); GHOST_AddEventConsumer(g_WS.ghost_system, consumer); diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index c0427f9be9a..ef609b740c5 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -23,6 +23,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_system.h" #include "BLI_utildefines.h" #include "BLT_translation.h" @@ -1543,6 +1544,8 @@ void wm_ghost_init(bContext *C) consumer = GHOST_CreateEventConsumer(ghost_event_proc, C); } + GHOST_SetBacktraceHandler((GHOST_TBacktraceFn)BLI_system_backtrace); + g_system = GHOST_CreateSystem(); GHOST_Debug debug = {0}; |