vcl/osx/salinst.cxx        |   13 -------------
 vcl/source/app/salplug.cxx |   23 +++++++++++++++++++++++
 vcl/win/app/salinst.cxx    |   19 -------------------
 3 files changed, 23 insertions(+), 32 deletions(-)

New commits:
commit f5af2104fc490b90510e36bbf1d2adec8017c594
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Sun Dec 13 22:35:21 2020 +0100
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Mon Dec 14 15:59:06 2020 +0100

    Fix and clean up SalAbort implementations on macOS and Windows
    
    Since "forever", SalAbort has been declared as non-exported in
    vcl/inc/salinst.hxx and (only) called from Application::Abort
    (vcl/source/app/svapp.cxx) in Library_vcl.  Its various implementations for
    different platforms have always been scattered across Library_vcl.
    
    For Windows, SalAbort was originally implemented in vcl/win/app/salinst.cxx,
    until 1698debed2993fc5f262aa3ebbdb32fc112ac556 "Implement Windows VCL 
backend as
    plugin" introduced an incompatible implementation in vcl/win/app/salplug.cxx
    (which was added to Library_vcl) and moved the original implementation in
    vcl/win/app/salinst.cxx from Library_vcl to Library_vclplug_win, where it 
thus
    became dead code (and where it now gets removed).
    
    For macOS, SalAbort was originally implemented in vcl/osx/salinst.cxx, until
    3af4e1a0825c5b11ae4ef58fc411378aab669387 "Implement MacOSX VCL backend as
    plugin" introduced a different implementation in vcl/osx/salplug.cxx (which 
was
    added to Library_vcl) and moved the original implementation in
    vcl/osx/salinst.cxx from Library_vcl to Library_vclplug_win, where it thus
    became dead code (and where it now gets removed).
    
    (In 0f3be2e19fa408d7069d586ccf04cb3f3eccd6b9 "Unify sal plugin loaders", 
the---
    identical---new implementations in vcl/osx/salinst.cxx and
    vcl/win/app/salinst.cxx where then consolidated with other---also 
identical---
    implementations in vcl/source/app/salplug.cxx.)
    
    For macOS, the original, now removed implementation in vcl/osx/salinst.cxx 
and
    the consolidated implementation in vcl/source/app/salplug.cxx only differed 
in
    an added
    
      CrashReporter::addKeyValue("AbortMessage", rErrorText, 
CrashReporter::Write);
    
    which is presumably harmless to add.
    
    But for Windows, the original, now removed implementation in
    vcl/win/app/salinst.cxx differed substantially from the consolidated
    implementation in vcl/source/app/salplug.cxx, which is updated here to 
reflect
    those differences.  The one thing that cannot easily be updated, though, is 
the
    
      //TODO: ImplFreeSalGDI();
    
    call, as ImplFreeSalGDI is defined in Library_vclplug_win.  I'll thus leave
    fixing that TODO for another commit (if calling ImplFreeSalGDI from 
SalAbort is
    even necessary, given that it ends in FatalAppExitW anyway)---my gut 
feeling is
    that the whole 1698debed2993fc5f262aa3ebbdb32fc112ac556 "Implement Windows 
VCL
    backend as plugin" was somewhat misguided.
    
    Change-Id: I641a3d7b1bc27ae14c38eb1ec0838bc04e4290d2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107666
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/vcl/osx/salinst.cxx b/vcl/osx/salinst.cxx
index 91b22e9b77ec..bbe6d9d704f7 100644
--- a/vcl/osx/salinst.cxx
+++ b/vcl/osx/salinst.cxx
@@ -186,19 +186,6 @@ void AquaSalInstance::AfterAppInit()
 #endif
 }
 
-void SalAbort( const OUString& rErrorText, bool bDumpCore )
-{
-    if( rErrorText.isEmpty() )
-        fprintf( stderr, "Application Error " );
-    else
-        fprintf( stderr, "%s ",
-            OUStringToOString( rErrorText, osl_getThreadTextEncoding() 
).getStr() );
-    if( bDumpCore )
-        abort();
-    else
-        _exit(1);
-}
-
 SalYieldMutex::SalYieldMutex()
     : m_aCodeBlock( nullptr )
 {
diff --git a/vcl/source/app/salplug.cxx b/vcl/source/app/salplug.cxx
index 1868853e93b8..c3e4e666e9d3 100644
--- a/vcl/source/app/salplug.cxx
+++ b/vcl/source/app/salplug.cxx
@@ -36,6 +36,7 @@
 #include <unistd.h>
 #else
 #include <saldatabasic.hxx>
+#include <o3tl/char16_t2wchar_t.hxx>
 #include <Windows.h>
 #endif
 
@@ -292,17 +293,39 @@ void DestroySalInstance( SalInstance *pInst )
 
 void SalAbort( const OUString& rErrorText, bool bDumpCore )
 {
+#if defined _WIN32
+    //TODO: ImplFreeSalGDI();
+#endif
+
     if( rErrorText.isEmpty() )
+    {
+#if defined _WIN32
+        // make sure crash reporter is triggered
+        RaiseException( 0, EXCEPTION_NONCONTINUABLE, 0, nullptr );
+        FatalAppExitW( 0, L"Application Error" );
+#else
         std::fprintf( stderr, "Application Error\n" );
+#endif
+    }
     else
     {
         CrashReporter::addKeyValue("AbortMessage", rErrorText, 
CrashReporter::Write);
+#if defined _WIN32
+        // make sure crash reporter is triggered
+        RaiseException( 0, EXCEPTION_NONCONTINUABLE, 0, nullptr );
+        FatalAppExitW( 0, o3tl::toW(rErrorText.getStr()) );
+#else
         std::fprintf( stderr, "%s\n", OUStringToOString(rErrorText, 
osl_getThreadTextEncoding()).getStr() );
+#endif
     }
+#if defined _WIN32
+    (void) bDumpCore;
+#else
     if( bDumpCore )
         abort();
     else
         _exit(1);
+#endif
 }
 
 const OUString& SalGetDesktopEnvironment()
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index 8bdc810bffa2..00069d82499b 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -73,25 +73,6 @@
 
 #include <postwin.h>
 
-void SalAbort( const OUString& rErrorText, bool )
-{
-    ImplFreeSalGDI();
-
-    if ( rErrorText.isEmpty() )
-    {
-        // make sure crash reporter is triggered
-        RaiseException( 0, EXCEPTION_NONCONTINUABLE, 0, nullptr );
-        FatalAppExitW( 0, L"Application Error" );
-    }
-    else
-    {
-        CrashReporter::addKeyValue("AbortMessage", rErrorText, 
CrashReporter::Write);
-        // make sure crash reporter is triggered
-        RaiseException( 0, EXCEPTION_NONCONTINUABLE, 0, nullptr );
-        FatalAppExitW( 0, o3tl::toW(rErrorText.getStr()) );
-    }
-}
-
 static LRESULT CALLBACK SalComWndProcW( HWND hWnd, UINT nMsg, WPARAM wParam, 
LPARAM lParam );
 
 class SalYieldMutex : public comphelper::SolarMutex
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to