Kaydet (Commit) cccc6bcf authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Don't access broken service mgr during bootstrap failure

...so that displaying a (non-translated) error box upon BE_UNO_SERVICEMANAGER
works after all.  Augment the error text with an exception message where
appropriate.  This allows to revert fdfb7a3c
"Related fdo#51252: Report uncaught exceptions with MessageBox on Windows" as
that was to catch and display failures from instantiating the service mgr.

Change-Id: I049a38e95342634796eb0e940e2ee8e55193c9d3
üst a0659cc4
......@@ -103,15 +103,16 @@ class Desktop : public Application
static ResMgr* GetDesktopResManager();
static CommandLineArgs& GetCommandLineArgs();
void HandleBootstrapErrors( BootstrapError );
void SetBootstrapError( BootstrapError nError )
void HandleBootstrapErrors(
BootstrapError nError, OUString const & aMessage );
void SetBootstrapError(
BootstrapError nError, OUString const & aMessage )
{
if ( m_aBootstrapError == BE_OK )
{
m_aBootstrapError = nError;
}
BootstrapError GetBootstrapError() const
{
return m_aBootstrapError;
m_aBootstrapErrorMessage = aMessage;
}
}
void SetBootstrapStatus( BootstrapStatus nStatus )
......@@ -135,8 +136,6 @@ class Desktop : public Application
void SetSplashScreenText( const ::rtl::OUString& rText );
void SetSplashScreenProgress( sal_Int32 );
static void ensureProcessServiceFactory();
private:
// Bootstrap methods
static ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > CreateApplicationServiceManager();
......@@ -159,9 +158,6 @@ class Desktop : public Application
void HandleBootstrapPathErrors( ::utl::Bootstrap::Status, const ::rtl::OUString& aMsg );
void StartSetup( const ::rtl::OUString& aParameters );
// Get a resource message string securely e.g. if resource cannot be retrieved return aFaultBackMsg
::rtl::OUString GetMsgString( sal_uInt16 nId, const ::rtl::OUString& aFaultBackMsg );
// Create a error message depending on bootstrap failure code and an optional file url
::rtl::OUString CreateErrorMsgString( utl::Bootstrap::FailureCode nFailureCode,
const ::rtl::OUString& aFileURL );
......@@ -200,6 +196,7 @@ class Desktop : public Application
bool m_bCleanedExtensionCache;
bool m_bServicesRegistered;
BootstrapError m_aBootstrapError;
OUString m_aBootstrapErrorMessage;
BootstrapStatus m_aBootstrapStatus;
std::auto_ptr< Lockfile > m_pLockfile;
......
This diff is collapsed.
......@@ -51,7 +51,6 @@
#define STR_BOOTSTRAP_ERR_NO_SUPPORT (RID_DESKTOP_STRING_START+107)
#define STR_BOOTSTRAP_ERR_LANGUAGE_MISSING (RID_DESKTOP_STRING_START+108)
#define STR_BOOTSTRAP_ERR_NO_SERVICE (RID_DESKTOP_STRING_START+120)
#define STR_BOOTSTRAP_ERR_NO_CFG_SERVICE (RID_DESKTOP_STRING_START+121)
#define STR_BOOTSTRAP_ERR_CFG_DATAACCESS (RID_DESKTOP_STRING_START+122)
#define STR_BOOTSTRAP_ERR_NO_PATHSET_SERVICE (RID_DESKTOP_STRING_START+123)
......
......@@ -88,11 +88,6 @@ String STR_BOOTSTRAP_ERR_LANGUAGE_MISSING
Text [ en-US ] = "The user interface language cannot be determined.";
};
String STR_BOOTSTRAP_ERR_NO_SERVICE
{
Text [ en-US ] = "The component manager is not available.";
};
String STR_BOOTSTRAP_ERR_NO_CFG_SERVICE
{
Text [ en-US ] = "The configuration service is not available.";
......
......@@ -38,21 +38,14 @@
#include <rtl/bootstrap.hxx>
#include <tools/extendapplicationenvironment.hxx>
#if defined WNT
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
int SVMain();
// -=-= main() -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
extern "C" int DESKTOP_DLLPUBLIC soffice_main()
{
#if defined ANDROID || defined WNT
#if defined ANDROID
try {
#endif
#if defined(ANDROID)
rtl::Bootstrap::setIniFilename(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file:///assets/program/lofficerc")));
#endif
......@@ -83,20 +76,10 @@ extern "C" int DESKTOP_DLLPUBLIC soffice_main()
}
#endif
return SVMain();
#if defined ANDROID || defined WNT
} catch (const ::com::sun::star::uno::Exception &e) {
#if defined ANDROID
} catch (const ::com::sun::star::uno::Exception &e) {
fprintf (stderr, "Not handled UNO exception at main: '%s'\n",
rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
#elif defined WNT
MessageBoxW(
0,
reinterpret_cast< LPCWSTR >(
rtl::OUString("Unhandled exception:\n" + e.Message).getStr()),
reinterpret_cast< LPCWSTR >(rtl::OUString("Fatal Error").getStr()),
(MB_OK | MB_ICONERROR | MB_DEFBUTTON1 | MB_TASKMODAL
| MB_SETFOREGROUND | MB_TOPMOST));
#endif
throw; // to get exception type printed
}
#endif
......
......@@ -106,9 +106,13 @@ rtl::OUString AquaSalSystem::GetDisplayScreenName( unsigned int nScreen )
return aRet;
}
static NSString* getStandardString( int nButtonId )
static NSString* getStandardString( int nButtonId, bool bUseResources )
{
rtl::OUString aText( Button::GetStandardText( nButtonId ) );
rtl::OUString aText;
if( bUseResources )
{
aText = Button::GetStandardText( nButtonId );
}
if( aText.isEmpty() ) // this is for bad cases, we might be missing the vcl resource
{
switch( nButtonId )
......@@ -127,7 +131,7 @@ static NSString* getStandardString( int nButtonId )
int AquaSalSystem::ShowNativeMessageBox( const rtl::OUString& rTitle,
const rtl::OUString& rMessage,
int nButtonCombination,
int nDefaultButton)
int nDefaultButton, bool bUseResources)
{
NSString* pTitle = CreateNSString( rTitle );
NSString* pMessage = CreateNSString( rMessage );
......@@ -166,11 +170,14 @@ int AquaSalSystem::ShowNativeMessageBox( const rtl::OUString& rTitle,
if( aButtonIds[nC].nDefaultButton == nDefaultButton )
{
if( aButtonIds[nC].nTextIds[0] != -1 )
pDefText = getStandardString( aButtonIds[nC].nTextIds[0] );
pDefText = getStandardString(
aButtonIds[nC].nTextIds[0], bUseResources );
if( aButtonIds[nC].nTextIds[1] != -1 )
pAltText = getStandardString( aButtonIds[nC].nTextIds[1] );
pAltText = getStandardString(
aButtonIds[nC].nTextIds[1], bUseResources );
if( aButtonIds[nC].nTextIds[2] != -1 )
pOthText = getStandardString( aButtonIds[nC].nTextIds[2] );
pOthText = getStandardString(
aButtonIds[nC].nTextIds[2], bUseResources );
break;
}
}
......
......@@ -47,6 +47,47 @@
using namespace com::sun::star;
namespace {
OUString GetNativeMessageBoxButtonText( int nButtonId, bool bUseResources )
{
OUString aText;
if( bUseResources )
{
aText = Button::GetStandardText( nButtonId );
}
if( aText.isEmpty() )
{
switch( nButtonId )
{
case BUTTON_OK:
aText = "OK";
break;
case BUTTON_CANCEL:
aText = "Cancel";
break;
case BUTTON_ABORT:
aText = "Abort";
break;
case BUTTON_RETRY:
aText = "Retry";
break;
case BUTTON_IGNORE:
aText = "Ignore";
break;
case BUTTON_YES:
aText = "Yes";
break;
case BUTTON_NO:
aText = "No";
break;
}
}
return aText;
}
}
SalGenericSystem::SalGenericSystem()
{
}
......@@ -56,7 +97,8 @@ SalGenericSystem::~SalGenericSystem()
}
int SalGenericSystem::ShowNativeMessageBox( const rtl::OUString& rTitle, const rtl::OUString& rMessage,
int nButtonCombination, int nDefaultButton )
int nButtonCombination, int nDefaultButton,
bool bUseResources )
{
int nDefButton = 0;
std::list< rtl::OUString > aButtons;
......@@ -67,15 +109,15 @@ int SalGenericSystem::ShowNativeMessageBox( const rtl::OUString& rTitle, const r
if( nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK ||
nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL )
{
aButtons.push_back( Button::GetStandardText( BUTTON_OK ) );
aButtons.push_back( GetNativeMessageBoxButtonText( BUTTON_OK, bUseResources ) );
nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK;
}
if( nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_YES_NO_CANCEL ||
nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_YES_NO )
{
aButtons.push_back( Button::GetStandardText( BUTTON_YES ) );
aButtons.push_back( GetNativeMessageBoxButtonText( BUTTON_YES, bUseResources ) );
nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_YES;
aButtons.push_back( Button::GetStandardText( BUTTON_NO ) );
aButtons.push_back( GetNativeMessageBoxButtonText( BUTTON_NO, bUseResources ) );
nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_NO;
if( nDefaultButton == SALSYSTEM_SHOWNATIVEMSGBOX_BTN_NO )
nDefButton = 1;
......@@ -86,21 +128,21 @@ int SalGenericSystem::ShowNativeMessageBox( const rtl::OUString& rTitle, const r
{
if( nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_RETRY_CANCEL )
{
aButtons.push_back( Button::GetStandardText( BUTTON_RETRY ) );
aButtons.push_back( GetNativeMessageBoxButtonText( BUTTON_RETRY, bUseResources ) );
nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_RETRY;
}
aButtons.push_back( Button::GetStandardText( BUTTON_CANCEL ) );
aButtons.push_back( GetNativeMessageBoxButtonText( BUTTON_CANCEL, bUseResources ) );
nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL;
if( nDefaultButton == SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL )
nDefButton = aButtons.size()-1;
}
if( nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_ABORT_RETRY_IGNORE )
{
aButtons.push_back( Button::GetStandardText( BUTTON_ABORT ) );
aButtons.push_back( GetNativeMessageBoxButtonText( BUTTON_ABORT, bUseResources ) );
nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_ABORT;
aButtons.push_back( Button::GetStandardText( BUTTON_RETRY ) );
aButtons.push_back( GetNativeMessageBoxButtonText( BUTTON_RETRY, bUseResources ) );
nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_RETRY;
aButtons.push_back( Button::GetStandardText( BUTTON_IGNORE ) );
aButtons.push_back( GetNativeMessageBoxButtonText( BUTTON_IGNORE, bUseResources ) );
nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_IGNORE;
switch( nDefaultButton )
{
......
......@@ -52,7 +52,7 @@ public:
virtual int ShowNativeMessageBox( const rtl::OUString& rTitle,
const rtl::OUString& rMessage,
int nButtonCombination,
int nDefaultButton);
int nDefaultButton, bool bUseResources);
};
......
......@@ -50,7 +50,7 @@ class VCL_DLLPUBLIC SalGenericSystem : public SalSystem
virtual int ShowNativeMessageBox( const rtl::OUString& rTitle,
const rtl::OUString& rMessage,
int nButtonCombination,
int nDefaultButton);
int nDefaultButton, bool bUseResources);
// simple helpers primarily for X Windowing W_CLASS hints
static const char *getFrameResName();
......
......@@ -46,7 +46,7 @@ public:
virtual int ShowNativeMessageBox( const rtl::OUString& rTitle,
const rtl::OUString& rMessage,
int nButtonCombination,
int nDefaultButton);
int nDefaultButton, bool bUseResources);
};
#endif // _SV_SALSYS_H
......
......@@ -133,6 +133,10 @@ public:
The effect of specifying a button that doesn't belong
to the specified button combination is undefined.
@param bUseResources
If false, assume initialization of the application failed early and do
not try to access any resources.
@returns the identifier of the button that was pressed by the user.
See button identifier above. If the function fails the
return value is 0.
......@@ -140,7 +144,8 @@ public:
virtual int ShowNativeMessageBox( const rtl::OUString& rTitle,
const rtl::OUString& rMessage,
int nButtonCombination,
int nDefaultButton) = 0;
int nDefaultButton,
bool bUseResources ) = 0;
};
SalSystem* ImplGetSalSystem();
......
......@@ -76,7 +76,7 @@ public:
virtual int ShowNativeMessageBox( const rtl::OUString& rTitle,
const rtl::OUString& rMessage,
int nButtonCombination,
int nDefaultButton);
int nDefaultButton, bool bUseResources);
bool initMonitors();
// discards monitorinfo; used by WM_DISPLAYCHANGED handler
void clearMonitors();
......
......@@ -106,9 +106,13 @@ rtl::OUString IosSalSystem::GetDisplayScreenName( unsigned int nScreen )
return aRet;
}
static NSString* getStandardString( int nButtonId )
static NSString* getStandardString( int nButtonId, bool bUseResources )
{
rtl::OUString aText( Button::GetStandardText( nButtonId ) );
rtl::OUString aText;
if( bUseResources )
{
aText = Button::GetStandardText( nButtonId );
}
if( ! aText.getLength() ) // this is for bad cases, we might be missing the vcl resource
{
switch( nButtonId )
......@@ -150,7 +154,7 @@ static NSString* getStandardString( int nButtonId )
int IosSalSystem::ShowNativeMessageBox( const rtl::OUString& rTitle,
const rtl::OUString& rMessage,
int nButtonCombination,
int nDefaultButton)
int nDefaultButton, bool bUseResources)
{
NSString* pTitle = CreateNSString( rTitle );
NSString* pMessage = CreateNSString( rMessage );
......@@ -189,11 +193,14 @@ int IosSalSystem::ShowNativeMessageBox( const rtl::OUString& rTitle,
if( aButtonIds[nC].nDefaultButton == nDefaultButton )
{
if( aButtonIds[nC].nTextIds[0] != -1 )
pDefText = getStandardString( aButtonIds[nC].nTextIds[0] );
pDefText = getStandardString(
aButtonIds[nC].nTextIds[0], bUseResources );
if( aButtonIds[nC].nTextIds[1] != -1 )
pAltText = getStandardString( aButtonIds[nC].nTextIds[1] );
pAltText = getStandardString(
aButtonIds[nC].nTextIds[1], bUseResources );
if( aButtonIds[nC].nTextIds[2] != -1 )
pOthText = getStandardString( aButtonIds[nC].nTextIds[2] );
pOthText = getStandardString(
aButtonIds[nC].nTextIds[2], bUseResources );
break;
}
}
......
......@@ -1716,7 +1716,7 @@ void Application::ShowNativeErrorBox(const String& sTitle ,
sTitle,
sMessage,
SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK,
SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK);
SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK, false);
if (btn != SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK) {
OSL_TRACE("ShowNativeMessageBox returned %d", btn);
}
......
......@@ -407,7 +407,7 @@ bool ImplInitAccessBridge(sal_Bool bAllowCancel, sal_Bool &rCancelled)
aTitle,
ReplaceJavaErrorMessages(aMessage.makeStringAndClear()),
SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL,
SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL);
SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL, true);
// Do not change the setting in case the user chooses to cancel
if( SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL == ret )
......@@ -430,7 +430,7 @@ bool ImplInitAccessBridge(sal_Bool bAllowCancel, sal_Bool &rCancelled)
aTitle,
ReplaceJavaErrorMessages(aMessage.makeStringAndClear()),
SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL,
SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL);
SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL, true);
// Do not change the setting in case the user chooses to cancel
if( SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL == ret )
......@@ -453,7 +453,7 @@ bool ImplInitAccessBridge(sal_Bool bAllowCancel, sal_Bool &rCancelled)
aTitle,
ReplaceJavaErrorMessages(aMessage.makeStringAndClear()),
SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL,
SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL);
SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL, true);
// Do not change the setting in case the user chooses to cancel
if( SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL == ret )
......@@ -476,7 +476,7 @@ bool ImplInitAccessBridge(sal_Bool bAllowCancel, sal_Bool &rCancelled)
aTitle,
ReplaceJavaErrorMessages(aMessage.makeStringAndClear()),
SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL,
SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL);
SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL, true);
// Do not change the setting in case the user chooses to cancel
if( SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL == ret )
......@@ -515,7 +515,7 @@ bool ImplInitAccessBridge(sal_Bool bAllowCancel, sal_Bool &rCancelled)
aTitle,
ReplaceJavaErrorMessages(aMessage.makeStringAndClear()),
SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL,
SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL);
SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL, true);
// Do not change the setting in case the user chooses to cancel
if( SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL == ret )
......@@ -529,7 +529,7 @@ bool ImplInitAccessBridge(sal_Bool bAllowCancel, sal_Bool &rCancelled)
aTitle,
ReplaceJavaErrorMessages(aMessage.makeStringAndClear()),
SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK,
SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK);
SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK, true);
}
}
}
......
......@@ -220,7 +220,7 @@ static int DEFAULT_BTN_MAPPING_TABLE[][8] =
{ MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON2, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1 } //RETRY_CANCEL
};
int WinSalSystem::ShowNativeMessageBox(const rtl::OUString& rTitle, const rtl::OUString& rMessage, int nButtonCombination, int nDefaultButton)
int WinSalSystem::ShowNativeMessageBox(const rtl::OUString& rTitle, const rtl::OUString& rMessage, int nButtonCombination, int nDefaultButton, SAL_UNUSED_PARAMETER bool)
{
DBG_ASSERT( nButtonCombination >= SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK &&
nButtonCombination <= SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_RETRY_CANCEL &&
......
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