diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2018-01-26 11:37:58 +0100 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2018-01-26 19:33:41 +0100 |
commit | 1710f23e2152ec53a9d90c9bff850c9f4f026053 (patch) | |
tree | c5dd8bdd3bb585c6232abbb511cae479c1bb9f71 /svtools | |
parent | 3dcf50fb383ebd8c38b1b931e41e3985adcc9bed (diff) |
Make handled flags for Java interaction handler static
In commit 5785e4f4ab9c0e30d709e6150bc7230098ed550b, initial work to only
show Java error dialogs once had been done. Still, in some cases, multiple
such dialogs can still be shown.
JavaInteractionHandler instances can be created in at least two contexts:
in JavaContext::getValueByName, and in DesktopContext::getValueByName.
Additionally, in the latter, it is not kept for subsequent reuse, but re-
created anew each time. So, it is possible that "Java Missing" (and friends)
dialogs will be shown multiple times per session. E.g., specific installed
extensions (not using Java, but rather Python) can trigger said behavior
in Desktop::doShutdown inside BackupFileHelper::tryPushExtensionInfo.
This patch makes the "already handled" flags static, thus sharing the
status among different handler instances.
Also, unchanged-after-const-initializing m_bShowErrorsOnce is removed.
Change-Id: I79d40639caa9764a04af9201c7e1a6fa624f03e5
Reviewed-on: https://gerrit.libreoffice.org/48678
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/java/javainteractionhandler.cxx | 52 |
1 files changed, 32 insertions, 20 deletions
diff --git a/svtools/source/java/javainteractionhandler.cxx b/svtools/source/java/javainteractionhandler.cxx index 6eb906a23005..311bbcb23d24 100644 --- a/svtools/source/java/javainteractionhandler.cxx +++ b/svtools/source/java/javainteractionhandler.cxx @@ -39,18 +39,30 @@ using namespace com::sun::star::uno; using namespace com::sun::star::task; +namespace +{ +static struct JavaEvents { + bool bDisabledHandled : 1; + bool bInvalidSettingsHandled : 1; + bool bNotFoundHandled : 1; + bool bVMCreationFailureHandled : 1; + bool bRestartRequiredHandled : 1; + sal_uInt16 nResult_JavaDisabled = RET_NO; + JavaEvents() + : bDisabledHandled(false) + , bInvalidSettingsHandled(false) + , bNotFoundHandled(false) + , bVMCreationFailureHandled(false) + , bRestartRequiredHandled(false) + {} +} g_JavaEvents; +} + namespace svt { JavaInteractionHandler::JavaInteractionHandler() : - m_aRefCount(0), - m_bShowErrorsOnce(true), - m_bJavaDisabled_Handled(false), - m_bInvalidSettings_Handled(false), - m_bJavaNotFound_Handled(false), - m_bVMCreationFailure_Handled(false), - m_bRestartRequired_Handled(false), - m_nResult_JavaDisabled(RET_NO) + m_aRefCount(0) { } @@ -113,11 +125,11 @@ void SAL_CALL JavaInteractionHandler::handle( const Reference< XInteractionReque if ( anyExc >>= e1 ) { - if( ! (m_bShowErrorsOnce && m_bJavaNotFound_Handled)) + if( !g_JavaEvents.bNotFoundHandled ) { // No suitable JRE found SolarMutexGuard aSolarGuard; - m_bJavaNotFound_Handled = true; + g_JavaEvents.bNotFoundHandled = true; #if defined( MACOSX ) ScopedVclPtrInstance< MessageDialog > aWarningBox(nullptr, SvtResId(STR_WARNING_JAVANOTFOUND_MAC), VclMessageType::Warning); #elif defined( _WIN32 ) @@ -141,11 +153,11 @@ void SAL_CALL JavaInteractionHandler::handle( const Reference< XInteractionReque } else if ( anyExc >>= e2 ) { - if( !(m_bShowErrorsOnce && m_bInvalidSettings_Handled)) + if( !g_JavaEvents.bInvalidSettingsHandled ) { // javavendors.xml was updated and Java has not been configured yet SolarMutexGuard aSolarGuard; - m_bInvalidSettings_Handled = true; + g_JavaEvents.bInvalidSettingsHandled = true; #ifdef MACOSX ScopedVclPtrInstance< MessageDialog > aWarningBox(nullptr, SvtResId(STR_WARNING_INVALIDJAVASETTINGS_MAC), VclMessageType::Warning); #else @@ -161,10 +173,10 @@ void SAL_CALL JavaInteractionHandler::handle( const Reference< XInteractionReque } else if ( anyExc >>= e3 ) { - if( !(m_bShowErrorsOnce && m_bJavaDisabled_Handled)) + if( !g_JavaEvents.bDisabledHandled ) { SolarMutexGuard aSolarGuard; - m_bJavaDisabled_Handled = true; + g_JavaEvents.bDisabledHandled = true; // Java disabled. Give user a chance to enable Java inside Office. ScopedVclPtrInstance<MessageDialog> aQueryBox(nullptr , "JavaDisabledDialog", "svt/ui/javadisableddialog.ui"); @@ -174,21 +186,21 @@ void SAL_CALL JavaInteractionHandler::handle( const Reference< XInteractionReque jfw_setEnabled(true); } - m_nResult_JavaDisabled = nResult; + g_JavaEvents.nResult_JavaDisabled = nResult; } else { - nResult = m_nResult_JavaDisabled; + nResult = g_JavaEvents.nResult_JavaDisabled; } } else if ( anyExc >>= e4 ) { - if( !(m_bShowErrorsOnce && m_bVMCreationFailure_Handled)) + if( !g_JavaEvents.bVMCreationFailureHandled ) { // Java not correctly installed, or damaged SolarMutexGuard aSolarGuard; - m_bVMCreationFailure_Handled = true; + g_JavaEvents.bVMCreationFailureHandled = true; #ifdef MACOSX ScopedVclPtrInstance< MessageDialog > aErrorBox(nullptr, SvtResId(STR_ERROR_JVMCREATIONFAILED_MAC)); #else @@ -204,12 +216,12 @@ void SAL_CALL JavaInteractionHandler::handle( const Reference< XInteractionReque } else if ( anyExc >>= e5 ) { - if( !(m_bShowErrorsOnce && m_bRestartRequired_Handled)) + if( !g_JavaEvents.bRestartRequiredHandled ) { // a new JRE was selected, but office needs to be restarted //before it can be used. SolarMutexGuard aSolarGuard; - m_bRestartRequired_Handled = true; + g_JavaEvents.bRestartRequiredHandled = true; svtools::executeRestartDialog( comphelper::getProcessComponentContext(), nullptr, svtools::RESTART_REASON_JAVA); |