[Libreoffice-commits] core.git: Branch 'libreoffice-5-2' - sal/osl

Michael Stahl mstahl at redhat.com
Wed Feb 1 13:49:55 UTC 2017


 sal/osl/w32/dllentry.c |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

New commits:
commit a9c50818c99dfee448862b18e2c5c8ba639200cf
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Jan 27 17:50:30 2017 +0100

    sal: add SAL_NO_ASSERT_DIALOGS variable to redirect...
    
    ... the dialogs that pop up on assert() and abort() to stderr, which
    should work better in CI builds.
    
    Change-Id: I80ec95bae6cc21b8ac27f68ca93aa6c6cce707f4
    (cherry picked from commit 2fc5a65a1808ce4304ea55f06c4587a2459b5d52)
    Reviewed-on: https://gerrit.libreoffice.org/33720
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sal/osl/w32/dllentry.c b/sal/osl/w32/dllentry.c
index 97536ce..21cebea 100644
--- a/sal/osl/w32/dllentry.c
+++ b/sal/osl/w32/dllentry.c
@@ -23,6 +23,9 @@
 #include <windows.h>
 #ifdef _MSC_VER
 #pragma warning(pop)
+#ifdef _DEBUG
+#include <crtdbg.h>
+#endif
 #endif
 #include <tlhelp32.h>
 #include <systools/win32/uwinapi.h>
@@ -148,6 +151,21 @@ static BOOL WINAPI _RawDllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvR
     {
         case DLL_PROCESS_ATTACH:
             {
+#ifdef _DEBUG
+                WCHAR buf[64];
+                DWORD const res = GetEnvironmentVariableW(L"SAL_NO_ASSERT_DIALOGS", buf, sizeof(buf));
+                if (res && res < sizeof(buf))
+                {
+                    // disable the dialog on abort()
+                    _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
+                    _CrtSetReportMode(_CRT_ERROR, (_CRTDBG_MODE_DEBUG|_CRTDBG_MODE_FILE));
+                    // not sure which assertions this affects
+                    _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
+                    _CrtSetReportMode(_CRT_ASSERT, (_CRTDBG_MODE_DEBUG|_CRTDBG_MODE_FILE));
+                    // disable the dialog on assert(false)
+                    _set_error_mode(_OUT_TO_STDERR);
+                }
+#endif
 #endif
 
 #if OSL_DEBUG_LEVEL < 2


More information about the Libreoffice-commits mailing list