include/tools/debug.hxx      |   20 ++++++--------------
 tools/source/debug/debug.cxx |   34 +++++++++++++++-------------------
 2 files changed, 21 insertions(+), 33 deletions(-)

New commits:
commit 6ab52cbb0ef1d2d08938d9355300155dbbb691fe
Author: Noel Grandin <n...@peralex.com>
Date:   Wed Jun 8 12:32:34 2016 +0200

    reduce "no DbgTestSolarMutex function set" warning
    
    Change-Id: I68c67e77a2759c8542dd4a44a78a9fcf8aa7dcc0
    Reviewed-on: https://gerrit.libreoffice.org/26056
    Reviewed-by: Noel Grandin <noelgran...@gmail.com>
    Tested-by: Noel Grandin <noelgran...@gmail.com>

diff --git a/include/tools/debug.hxx b/include/tools/debug.hxx
index 4ad9022..3f5d68a 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 edb4ffe..dafd60a 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
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to