Kaydet (Commit) 7d902940 authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Noel Grandin

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/24892Reviewed-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
Tested-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
üst c2f912b5
......@@ -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()
......
......@@ -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;
......
......@@ -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 );
......
......@@ -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
......
......@@ -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.
......
......@@ -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()
......
......@@ -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:
......
......@@ -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;
......
......@@ -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;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment