diff options
-rw-r--r-- | extensions/source/ole/unoobjw.cxx | 6 | ||||
-rw-r--r-- | include/comphelper/asyncquithandler.hxx | 14 | ||||
-rw-r--r-- | vbahelper/source/vbahelper/vbaapplicationbase.cxx | 4 |
3 files changed, 21 insertions, 3 deletions
diff --git a/extensions/source/ole/unoobjw.cxx b/extensions/source/ole/unoobjw.cxx index bc166d979b63..6f25babcc81c 100644 --- a/extensions/source/ole/unoobjw.cxx +++ b/extensions/source/ole/unoobjw.cxx @@ -85,6 +85,7 @@ #include <osl/interlck.h> #include <com/sun/star/uno/genfunc.h> #include <comphelper/automationinvokedzone.hxx> +#include <comphelper/asyncquithandler.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/profilezone.hxx> #include <comphelper/windowsdebugoutput.hxx> @@ -148,8 +149,9 @@ public: void SAL_CALL queryTermination( const EventObject& ) override { SAL_INFO("extensions.olebridge", "TerminationVetoer::queryTermination: count=" << mnCount); - // Always veto termination while an OLE object is active - if (mnCount > 0) + // Always veto termination while an OLE object is active, except if it is an OLE object that + // has asked us to quit. + if (!AsyncQuitHandler::instance().IsForceQuit() && mnCount > 0) { SAL_INFO("extensions.olebridge", "TerminationVetoer::queryTermination: Throwing!"); throw css::frame::TerminationVetoException(); diff --git a/include/comphelper/asyncquithandler.hxx b/include/comphelper/asyncquithandler.hxx index 9c7a3c1a6289..a20ac99da64f 100644 --- a/include/comphelper/asyncquithandler.hxx +++ b/include/comphelper/asyncquithandler.hxx @@ -31,7 +31,12 @@ class AsyncQuitHandler { - AsyncQuitHandler() {} + AsyncQuitHandler() + : mbForceQuit(false) + { + } + + bool mbForceQuit; public: AsyncQuitHandler(const AsyncQuitHandler&) = delete; @@ -50,6 +55,13 @@ public: xDesktop->terminate(); } + // Hack for the TerminationVetoer in extensions/source/ole/unoobjw.cxx. When it is an Automation + // client itself that explicitly requests a quit (see VbaApplicationBase::Quit()), we do quit. + // The flag can only be set to true, not back to false. + void SetForceQuit() { mbForceQuit = true; } + + bool IsForceQuit() { return mbForceQuit; } + DECL_STATIC_LINK(AsyncQuitHandler, OnAsyncQuit, void*, void); }; diff --git a/vbahelper/source/vbahelper/vbaapplicationbase.cxx b/vbahelper/source/vbahelper/vbaapplicationbase.cxx index 82bcf256ace5..87c82e472d7c 100644 --- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx +++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx @@ -472,9 +472,13 @@ void VbaApplicationBase::Quit() { // This is the case of a call from an (OLE) Automation client. + // When an Automation client itself asks the proces to quit, it should obey it. + AsyncQuitHandler::instance().SetForceQuit(); + // TODO: Probably we should just close any document windows open by the "application" // (Writer or Calc) the call being handled is for. And only then, if no document windows // are left open, quit the actual LibreOffice application. + Application::PostUserEvent( LINK( &AsyncQuitHandler::instance(), AsyncQuitHandler, OnAsyncQuit ) ); } } |