[Libreoffice-commits] core.git: canvas/workben desktop/inc desktop/source include/vcl slideshow/test vcl/source vcl/workben
Noel Grandin
noel at peralex.com
Fri May 13 06:30:07 UTC 2016
canvas/workben/canvasdemo.cxx | 9 ++--
desktop/inc/app.hxx | 2 -
desktop/source/app/app.cxx | 8 ++--
include/vcl/exceptiontypes.hxx | 8 +---
include/vcl/svapp.hxx | 11 +-----
slideshow/test/demoshow.cxx | 9 ++--
vcl/source/app/svapp.cxx | 10 ++---
vcl/source/app/svmain.cxx | 74 +++++++++++++++++++----------------------
vcl/workben/outdevgrind.cxx | 9 ++--
9 files changed, 65 insertions(+), 75 deletions(-)
New commits:
commit 7d902940508decad933c19bc97e5409873ab5189
Author: Noel Grandin <noel at peralex.com>
Date: Wed May 11 16:10:39 2016 +0200
convert EXCEPTION_ to scoped enum
- simplify VCLExceptionSignal_impl
- drop "minor" part of error code, nobody passes it in, and nobody
checks it
- rename Display to UserInterface, to prevent -Werror=shadow
Change-Id: I503fd8a50ded30d59c30fb388796f6b1a0c058de
Reviewed-on: https://gerrit.libreoffice.org/24892
Reviewed-by: Noel Grandin <noelgrandin at gmail.com>
Tested-by: Noel Grandin <noelgrandin at gmail.com>
diff --git a/canvas/workben/canvasdemo.cxx b/canvas/workben/canvasdemo.cxx
index 4a8143c..af2319a 100644
--- a/canvas/workben/canvasdemo.cxx
+++ b/canvas/workben/canvasdemo.cxx
@@ -64,7 +64,7 @@ class DemoApp : public Application
{
public:
virtual void Main();
- virtual USHORT Exception( USHORT nError );
+ virtual void Exception( ExceptionCategory nCategory );
};
static void PrintHelp()
@@ -621,15 +621,14 @@ void TestWindow::Paint( const Rectangle& /*rRect*/ )
}
}
-USHORT DemoApp::Exception( USHORT nError )
+void DemoApp::Exception( ExceptionCategory nCategory )
{
- switch( nError & EXCEPTION_MAJORTYPE )
+ switch( nCategory )
{
- case EXCEPTION_RESOURCENOTLOADED:
+ case ExceptionCategory::ResourceNotLoaded:
Abort( "Error: could not load language resources.\nPlease check your installation.\n" );
break;
}
- return 0;
}
void DemoApp::Main()
diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx
index 3bcc098..1905cf0 100644
--- a/desktop/inc/app.hxx
+++ b/desktop/inc/app.hxx
@@ -76,7 +76,7 @@ class Desktop : public Application
virtual void InitFinished() override;
virtual void DeInit() override;
virtual bool QueryExit() override;
- virtual void Exception(sal_uInt16 nError) override;
+ virtual void Exception(ExceptionCategory nCategory) override;
virtual void OverrideSystemSettings( AllSettings& rSettings ) override;
virtual void AppEvent( const ApplicationEvent& rAppEvent ) override;
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 133c4c5..847381c 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -1223,7 +1223,7 @@ void restartOnMac(bool passArguments) {
}
-void Desktop::Exception(sal_uInt16 nError)
+void Desktop::Exception(ExceptionCategory nCategory)
{
// protect against recursive calls
static bool bInException = false;
@@ -1244,7 +1244,7 @@ void Desktop::Exception(sal_uInt16 nError)
bool bAllowRecoveryAndSessionManagement = (
( !rArgs.IsNoRestore() ) && // some use cases of office must work without recovery
( !rArgs.IsHeadless() ) &&
- (( nError & EXCEPTION_MAJORTYPE ) != EXCEPTION_DISPLAY ) && // recovery can't work without UI ... but UI layer seems to be the reason for this crash
+ ( nCategory != ExceptionCategory::UserInterface ) && // recovery can't work without UI ... but UI layer seems to be the reason for this crash
( Application::IsInExecute() ) // crashes during startup and shutdown should be ignored (they indicates a corrupt installation ...)
);
if ( bAllowRecoveryAndSessionManagement )
@@ -1252,9 +1252,9 @@ void Desktop::Exception(sal_uInt16 nError)
FlushConfiguration();
- switch( nError & EXCEPTION_MAJORTYPE )
+ switch( nCategory )
{
- case EXCEPTION_RESOURCENOTLOADED:
+ case ExceptionCategory::ResourceNotLoaded:
{
OUString aResExceptionString;
Application::Abort( aResExceptionString );
diff --git a/include/vcl/exceptiontypes.hxx b/include/vcl/exceptiontypes.hxx
index bdf044a..bde3f5f 100644
--- a/include/vcl/exceptiontypes.hxx
+++ b/include/vcl/exceptiontypes.hxx
@@ -20,11 +20,9 @@
#ifndef INCLUDED_VCL_EXCEPTIONTYPES_HXX
#define INCLUDED_VCL_EXCEPTIONTYPES_HXX
-#define EXCEPTION_RESOURCENOTLOADED ((sal_uInt16)0x0100)
-#define EXCEPTION_SYSTEM ((sal_uInt16)0x0300)
-#define EXCEPTION_DISPLAY ((sal_uInt16)0x0400)
-#define EXCEPTION_MAJORTYPE ((sal_uInt16)0xFF00)
-#define EXCEPTION_MINORTYPE ((sal_uInt16)0x00FF)
+enum class ExceptionCategory {
+ NONE, ResourceNotLoaded, System, UserInterface
+};
#endif // INCLUDED_VCL_EXCEPTIONTYPES_HXX
diff --git a/include/vcl/svapp.hxx b/include/vcl/svapp.hxx
index 639433b..7d190b9 100644
--- a/include/vcl/svapp.hxx
+++ b/include/vcl/svapp.hxx
@@ -421,18 +421,13 @@ public:
@{
*/
- /** Handles an error code.
+ /** Handles an error.
- @remark This is not actually an exception. It merely takes an
- error code, then in most cases aborts. The list of exception
- identifiers can be found at include/vcl/inputtypes.hxx - each
- one starts with EXC_*
-
- @param nError The error code identifier
+ @param nCategory The error category, see include/vcl/exceptiontypes.hxx
@see Abort
*/
- virtual void Exception( sal_uInt16 nError );
+ virtual void Exception( ExceptionCategory nCategory );
/** Ends the program prematurely with an error message.
diff --git a/slideshow/test/demoshow.cxx b/slideshow/test/demoshow.cxx
index 17560f8..1183c7d 100644
--- a/slideshow/test/demoshow.cxx
+++ b/slideshow/test/demoshow.cxx
@@ -301,7 +301,7 @@ class DemoApp : public Application
{
public:
virtual void Main();
- virtual sal_uInt16 Exception( sal_uInt16 nError );
+ virtual void Exception( ExceptionCategory nCategory );
};
class ChildWindow : public vcl::Window
@@ -481,15 +481,14 @@ void DemoWindow::Resize()
// TODO
}
-sal_uInt16 DemoApp::Exception( sal_uInt16 nError )
+void DemoApp::Exception( ExceptionCategory nCategory )
{
- switch( nError & EXCEPTION_MAJORTYPE )
+ switch( nCategory )
{
- case EXCEPTION_RESOURCENOTLOADED:
+ case ExceptionCategory::ResourceNotLoaded:
Abort( "Error: could not load language resources.\nPlease check your installation.\n" );
break;
}
- return 0;
}
void DemoApp::Main()
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 1374a7a..be670e0 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -279,17 +279,17 @@ OUString Application::GetAppFileName()
return aAppFileName;
}
-void Application::Exception( sal_uInt16 nError )
+void Application::Exception( ExceptionCategory nCategory )
{
- switch ( nError & EXCEPTION_MAJORTYPE )
+ switch ( nCategory )
{
// System has precedence (so do nothing)
- case EXCEPTION_SYSTEM:
- case EXCEPTION_DISPLAY:
+ case ExceptionCategory::System:
+ case ExceptionCategory::UserInterface:
break;
#ifdef DBG_UTIL
- case EXCEPTION_RESOURCENOTLOADED:
+ case ExceptionCategory::ResourceNotLoaded:
Abort("Resource not loaded");
break;
default:
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index 39e62315..2b315b2 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -102,52 +102,50 @@ oslSignalAction SAL_CALL VCLExceptionSignal_impl( void* /*pData*/, oslSignalInfo
static volatile bool bIn = false;
// if we crash again, bail out immediately
- if ( !bIn )
- {
- sal_uInt16 nVCLException = 0;
+ if ( bIn )
+ return osl_Signal_ActCallNextHdl;
- // UAE
- if ( (pInfo->Signal == osl_Signal_AccessViolation) ||
- (pInfo->Signal == osl_Signal_IntegerDivideByZero) ||
- (pInfo->Signal == osl_Signal_FloatDivideByZero) ||
- (pInfo->Signal == osl_Signal_DebugBreak) )
- {
- nVCLException = EXCEPTION_SYSTEM;
+ ExceptionCategory nVCLException = ExceptionCategory::NONE;
+
+ // UAE
+ if ( (pInfo->Signal == osl_Signal_AccessViolation) ||
+ (pInfo->Signal == osl_Signal_IntegerDivideByZero) ||
+ (pInfo->Signal == osl_Signal_FloatDivideByZero) ||
+ (pInfo->Signal == osl_Signal_DebugBreak) )
+ {
+ nVCLException = ExceptionCategory::System;
#if HAVE_FEATURE_OPENGL
- if (OpenGLZone::isInZone())
- OpenGLZone::hardDisable();
+ if (OpenGLZone::isInZone())
+ OpenGLZone::hardDisable();
#endif
- }
+ }
+
+ // RC
+ if ((pInfo->Signal == osl_Signal_User) &&
+ (pInfo->UserSignal == OSL_SIGNAL_USER_RESOURCEFAILURE) )
+ nVCLException = ExceptionCategory::ResourceNotLoaded;
- // RC
- if ((pInfo->Signal == osl_Signal_User) &&
- (pInfo->UserSignal == OSL_SIGNAL_USER_RESOURCEFAILURE) )
- nVCLException = EXCEPTION_RESOURCENOTLOADED;
+ // DISPLAY-Unix
+ if ((pInfo->Signal == osl_Signal_User) &&
+ (pInfo->UserSignal == OSL_SIGNAL_USER_X11SUBSYSTEMERROR) )
+ nVCLException = ExceptionCategory::UserInterface;
+
+ if ( nVCLException != ExceptionCategory::NONE )
+ {
+ bIn = true;
- // DISPLAY-Unix
- if ((pInfo->Signal == osl_Signal_User) &&
- (pInfo->UserSignal == OSL_SIGNAL_USER_X11SUBSYSTEMERROR) )
- nVCLException = EXCEPTION_DISPLAY;
+ SolarMutexGuard aLock;
- if ( nVCLException )
+ // do not stop timer because otherwise the UAE-Box will not be painted as well
+ ImplSVData* pSVData = ImplGetSVData();
+ if ( pSVData->mpApp )
{
- bIn = true;
-
- SolarMutexGuard aLock;
-
- // do not stop timer because otherwise the UAE-Box will not be painted as well
- ImplSVData* pSVData = ImplGetSVData();
- if ( pSVData->mpApp )
- {
- SystemWindowFlags nOldMode = Application::GetSystemWindowMode();
- Application::SetSystemWindowMode( nOldMode & ~SystemWindowFlags::NOAUTOMODE );
- pSVData->mpApp->Exception( nVCLException );
- Application::SetSystemWindowMode( nOldMode );
- }
- bIn = false;
-
- return osl_Signal_ActCallNextHdl;
+ SystemWindowFlags nOldMode = Application::GetSystemWindowMode();
+ Application::SetSystemWindowMode( nOldMode & ~SystemWindowFlags::NOAUTOMODE );
+ pSVData->mpApp->Exception( nVCLException );
+ Application::SetSystemWindowMode( nOldMode );
}
+ bIn = false;
}
return osl_Signal_ActCallNextHdl;
diff --git a/vcl/workben/outdevgrind.cxx b/vcl/workben/outdevgrind.cxx
index 11b3125..e6ff4f4 100644
--- a/vcl/workben/outdevgrind.cxx
+++ b/vcl/workben/outdevgrind.cxx
@@ -57,7 +57,7 @@ class GrindApp : public Application
{
public:
virtual int Main() override;
- virtual void Exception( sal_uInt16 nError ) override;
+ virtual void Exception( ExceptionCategory nCategory ) override;
};
class TestWindow : public Dialog
@@ -669,13 +669,14 @@ void TestWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
fflush(stdout);
}
-void GrindApp::Exception( sal_uInt16 nError )
+void GrindApp::Exception( ExceptionCategory nCategory )
{
- switch( nError & EXCEPTION_MAJORTYPE )
+ switch( nCategory )
{
- case EXCEPTION_RESOURCENOTLOADED:
+ case ExceptionCategory::ResourceNotLoaded:
Abort( "Error: could not load language resources.\nPlease check your installation.\n" );
break;
+ default: break;
}
}
More information about the Libreoffice-commits
mailing list