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 /intern/ghost | |
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.
Diffstat (limited to 'intern/ghost')
-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 |
5 files changed, 30 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; +} |