diff options
-rw-r--r-- | include/tools/debug.hxx | 20 | ||||
-rw-r--r-- | tools/source/debug/debug.cxx | 34 |
2 files changed, 21 insertions, 33 deletions
diff --git a/include/tools/debug.hxx b/include/tools/debug.hxx index 4ad90223e52f..3f5d68a670e4 100644 --- a/include/tools/debug.hxx +++ b/include/tools/debug.hxx @@ -39,21 +39,13 @@ typedef void (*DbgTestSolarMutexProc)(); -// Dbg prototypes -#define DBG_FUNC_SETTESTSOLARMUTEX 2 -#define DBG_FUNC_TESTSOLARMUTEX 3 +TOOLS_DLLPUBLIC void DbgSetTestSolarMutex( DbgTestSolarMutexProc pParam ); +TOOLS_DLLPUBLIC void DbgTestSolarMutex(); -TOOLS_DLLPUBLIC void* DbgFunc( sal_uInt16 nAction, void* pData = nullptr ); - -inline void DbgSetTestSolarMutex( DbgTestSolarMutexProc pProc ) -{ - DbgFunc( DBG_FUNC_SETTESTSOLARMUTEX, reinterpret_cast<void*>(reinterpret_cast<sal_uIntPtr>(pProc)) ); -} - -#define DBG_TESTSOLARMUTEX() \ -do \ -{ \ - DbgFunc(DBG_FUNC_TESTSOLARMUTEX); \ +#define DBG_TESTSOLARMUTEX() \ +do \ +{ \ + DbgTestSolarMutex(); \ } while(false) #else diff --git a/tools/source/debug/debug.cxx b/tools/source/debug/debug.cxx index edb4ffe8b7dc..dafd60a74d59 100644 --- a/tools/source/debug/debug.cxx +++ b/tools/source/debug/debug.cxx @@ -47,35 +47,31 @@ struct DebugData { DbgTestSolarMutexProc pDbgTestSolarMutex; + bool bTestSolarMutexWasSet; DebugData() - :pDbgTestSolarMutex( nullptr ) + :pDbgTestSolarMutex( nullptr ), bTestSolarMutexWasSet(false) { } }; static DebugData aDebugData; -void* DbgFunc( sal_uInt16 nAction, void* pParam ) +void DbgSetTestSolarMutex( DbgTestSolarMutexProc pParam ) { - DebugData* pDebugData = &aDebugData; - - switch ( nAction ) - { - case DBG_FUNC_SETTESTSOLARMUTEX: - pDebugData->pDbgTestSolarMutex = reinterpret_cast<DbgTestSolarMutexProc>(reinterpret_cast<sal_uIntPtr>(pParam)); - break; - - case DBG_FUNC_TESTSOLARMUTEX: - SAL_WARN_IF( - pDebugData->pDbgTestSolarMutex == nullptr, "tools.debug", - "no DbgTestSolarMutex function set"); - if ( pDebugData->pDbgTestSolarMutex ) - pDebugData->pDbgTestSolarMutex(); - break; - } + aDebugData.pDbgTestSolarMutex = pParam; + if (pParam) + aDebugData.bTestSolarMutexWasSet = true; +} - return nullptr; +void DbgTestSolarMutex() +{ + // don't warn if it was set at least once, because then we're probably just post-DeInitVCL() + SAL_WARN_IF( + !aDebugData.bTestSolarMutexWasSet && aDebugData.pDbgTestSolarMutex == nullptr, "tools.debug", + "no DbgTestSolarMutex function set"); + if ( aDebugData.pDbgTestSolarMutex ) + aDebugData.pDbgTestSolarMutex(); } #endif |