From 2b47c5f295589acb18d4404137c6b72d20f019b6 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 8 Jun 2020 15:45:10 +0200 Subject: remove the fake SvxScriptErrorDialog code which just forwards to an async real dialog. Change-Id: I61936c4d105b9829042817e6a3cf5e60c451fb6b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95830 Tested-by: Jenkins Reviewed-by: Noel Grandin --- cui/source/dialogs/scriptdlg.cxx | 54 +++++++--------------- cui/source/factory/dlgfact.cxx | 4 +- cui/source/factory/dlgfact.hxx | 2 +- cui/source/inc/scriptdlg.hxx | 14 +++--- include/sfx2/sfxdlg.hxx | 2 +- include/svx/svxdlg.hxx | 2 +- scripting/source/protocolhandler/scripthandler.cxx | 4 +- sfx2/source/doc/objmisc.cxx | 4 +- 8 files changed, 29 insertions(+), 57 deletions(-) diff --git a/cui/source/dialogs/scriptdlg.cxx b/cui/source/dialogs/scriptdlg.cxx index 3ce12bccf290..ed09844aa771 100644 --- a/cui/source/dialogs/scriptdlg.cxx +++ b/cui/source/dialogs/scriptdlg.cxx @@ -59,12 +59,6 @@ using namespace css::script; using namespace css::frame; using namespace css::document; -static void ShowErrorDialog( const Any& aException ) -{ - ScopedVclPtrInstance pDlg( aException ); - pDlg->Execute(); -} - void SvxScriptOrgDialog::delUserData(const weld::TreeIter& rIter) { SFEntry* pUserData = reinterpret_cast(m_xScriptsBox->get_id(rIter).toInt64()); @@ -626,19 +620,19 @@ IMPL_LINK(SvxScriptOrgDialog, ButtonHdl, weld::Button&, rButton, void) } catch ( reflection::InvocationTargetException& ite ) { - ShowErrorDialog(css::uno::Any(ite)); + SvxScriptErrorDialog::ShowAsyncErrorDialog(getDialog(), css::uno::Any(ite)); } catch ( provider::ScriptFrameworkErrorException& ite ) { - ShowErrorDialog(css::uno::Any(ite)); + SvxScriptErrorDialog::ShowAsyncErrorDialog(getDialog(), css::uno::Any(ite)); } catch ( RuntimeException& re ) { - ShowErrorDialog(css::uno::Any(re)); + SvxScriptErrorDialog::ShowAsyncErrorDialog(getDialog(), css::uno::Any(re)); } catch ( Exception& e ) { - ShowErrorDialog(css::uno::Any(e)); + SvxScriptErrorDialog::ShowAsyncErrorDialog(getDialog(), css::uno::Any(e)); } } StoreCurrentSelection(); @@ -1300,50 +1294,34 @@ OUString GetErrorMessage( const css::uno::Any& aException ) } -SvxScriptErrorDialog::SvxScriptErrorDialog( css::uno::Any const & aException ) - : m_sMessage() +// Show Error dialog asynchronously +void SvxScriptErrorDialog::ShowAsyncErrorDialog( weld::Window* pParent, css::uno::Any const & aException ) { SolarMutexGuard aGuard; - m_sMessage = GetErrorMessage( aException ); -} - -SvxScriptErrorDialog::~SvxScriptErrorDialog() -{ -} - -short SvxScriptErrorDialog::Execute() -{ - // Show Error dialog asynchronously + OUString sMessage = GetErrorMessage( aException ); // Pass a copy of the message to the ShowDialog method as the // SvxScriptErrorDialog may be deleted before ShowDialog is called + DialogData* pData = new DialogData; + pData->sMessage = sMessage; + pData->pParent = pParent; Application::PostUserEvent( - LINK( this, SvxScriptErrorDialog, ShowDialog ), - new OUString( m_sMessage ) ); - - return 0; + LINK( nullptr, SvxScriptErrorDialog, ShowDialog ), + pData ); } IMPL_STATIC_LINK( SvxScriptErrorDialog, ShowDialog, void*, p, void ) { - OUString* pMessage = static_cast(p); - OUString message; + std::unique_ptr xData(static_cast(p)); + OUString message = xData->sMessage; - if ( pMessage && !pMessage->isEmpty() ) - { - message = *pMessage; - } - else - { + if ( message.isEmpty() ) message = CuiResId( RID_SVXSTR_ERROR_TITLE ); - } - std::unique_ptr xBox(Application::CreateMessageDialog(nullptr, + std::unique_ptr xBox(Application::CreateMessageDialog(xData->pParent, VclMessageType::Warning, VclButtonsType::Ok, message)); xBox->set_title(CuiResId(RID_SVXSTR_ERROR_TITLE)); xBox->run(); - - delete pMessage; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx index 40102bae726a..5784e4e31fc1 100644 --- a/cui/source/factory/dlgfact.cxx +++ b/cui/source/factory/dlgfact.cxx @@ -1123,9 +1123,9 @@ VclPtr AbstractDialogFactory_Impl::CreateActualizeProgressDia return VclPtr::Create(std::make_unique(pParent, pThm)); } -VclPtr AbstractDialogFactory_Impl::CreateScriptErrorDialog(const css::uno::Any& rException) +void AbstractDialogFactory_Impl::ShowAsyncScriptErrorDialog(weld::Window* pParent, const css::uno::Any& rException) { - return VclPtr::Create(rException); + return SvxScriptErrorDialog::ShowAsyncErrorDialog(pParent, rException); } VclPtr AbstractDialogFactory_Impl::CreateScriptSelectorDialog(weld::Window* pParent, diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx index 4f54b03f91d4..89f9ef88a824 100644 --- a/cui/source/factory/dlgfact.hxx +++ b/cui/source/factory/dlgfact.hxx @@ -930,7 +930,7 @@ public: virtual VclPtr CreateScriptSelectorDialog(weld::Window* pParent, const css::uno::Reference< css::frame::XFrame >& rxFrame) override; - virtual VclPtr CreateScriptErrorDialog(const css::uno::Any& rException) override; + virtual void ShowAsyncScriptErrorDialog(weld::Window* pParent, const css::uno::Any& rException) override; virtual VclPtr CreateSvxMacroAssignDlg( weld::Window* _pParent, diff --git a/cui/source/inc/scriptdlg.hxx b/cui/source/inc/scriptdlg.hxx index dc2e771b9187..8e66fed69a04 100644 --- a/cui/source/inc/scriptdlg.hxx +++ b/cui/source/inc/scriptdlg.hxx @@ -150,21 +150,19 @@ public: virtual short run() override; }; -class SvxScriptErrorDialog : public VclAbstractDialog +class SvxScriptErrorDialog { private: - - OUString m_sMessage; + struct DialogData { + weld::Window* pParent; + OUString sMessage; + }; DECL_STATIC_LINK( SvxScriptErrorDialog, ShowDialog, void*, void ); public: - SvxScriptErrorDialog( css::uno::Any const & aException ); - - virtual ~SvxScriptErrorDialog() override; - - short Execute() override; + static void ShowAsyncErrorDialog( weld::Window* pParent, css::uno::Any const & aException ); }; #endif // INCLUDED_CUI_SOURCE_INC_SCRIPTDLG_HXX diff --git a/include/sfx2/sfxdlg.hxx b/include/sfx2/sfxdlg.hxx index 6d03dc0f80b0..26378ffb754c 100644 --- a/include/sfx2/sfxdlg.hxx +++ b/include/sfx2/sfxdlg.hxx @@ -139,7 +139,7 @@ public: virtual VclPtr CreateScriptSelectorDialog(weld::Window* pParent, const css::uno::Reference< css::frame::XFrame >& rxFrame) = 0; - virtual VclPtr CreateScriptErrorDialog( const css::uno::Any& rException ) = 0; + virtual void ShowAsyncScriptErrorDialog( weld::Window* pParent, const css::uno::Any& rException ) = 0; virtual VclPtr CreateOptionsDialog( weld::Window* pParent, const OUString& rExtensionId ) = 0; diff --git a/include/svx/svxdlg.hxx b/include/svx/svxdlg.hxx index 7fb3767ad742..c07db29b516f 100644 --- a/include/svx/svxdlg.hxx +++ b/include/svx/svxdlg.hxx @@ -440,7 +440,7 @@ public: virtual VclPtr CreateScriptSelectorDialog(weld::Window* pParent, const css::uno::Reference< css::frame::XFrame >& rxFrame) override = 0; - virtual VclPtr CreateScriptErrorDialog(const css::uno::Any& rException) override = 0; + virtual void ShowAsyncScriptErrorDialog(weld::Window* pParent, const css::uno::Any& rException) override = 0; virtual VclPtr CreateSvxMacroAssignDlg( weld::Window* _pParent, diff --git a/scripting/source/protocolhandler/scripthandler.cxx b/scripting/source/protocolhandler/scripthandler.cxx index 74aecbeb1e5c..e55926952f70 100644 --- a/scripting/source/protocolhandler/scripthandler.cxx +++ b/scripting/source/protocolhandler/scripthandler.cxx @@ -261,9 +261,7 @@ void SAL_CALL ScriptProtocolHandler::dispatchWithNotification( if ( bCaughtException ) { SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); - ScopedVclPtr pDlg( - pFact->CreateScriptErrorDialog( aException )); - pDlg->Execute(); + pFact->ShowAsyncScriptErrorDialog( nullptr, aException ); } if ( !xListener.is() ) diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index e3e07dd5c306..e9adb018eae0 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -1435,9 +1435,7 @@ ErrCode SfxObjectShell::CallXScript( const Reference< XInterface >& _rxScriptCon if ( bCaughtException && bRaiseError ) { SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); - ScopedVclPtr pScriptErrDlg( pFact->CreateScriptErrorDialog( aException ) ); - if ( pScriptErrDlg ) - pScriptErrDlg->Execute(); + pFact->ShowAsyncScriptErrorDialog( nullptr, aException ); } SAL_INFO("sfx", "leaving CallXScript" ); -- cgit