extensions/source/ole/unoobjw.cxx | 6 ++++-- include/comphelper/asyncquithandler.hxx | 14 +++++++++++++- vbahelper/source/vbahelper/vbaapplicationbase.cxx | 4 ++++ 3 files changed, 21 insertions(+), 3 deletions(-)
New commits: commit 505d8ecae6465ac8fc1332b8ecddcd7576547b9f Author: Tor Lillqvist <t...@collabora.com> AuthorDate: Wed Aug 21 11:57:28 2019 +0300 Commit: Tor Lillqvist <t...@collabora.com> CommitDate: Fri Sep 20 15:34:10 2019 +0200 More hacks for quit requests from an OLE Automation client Actually I am now not so sure whether the TerminationVetoer thing is needed or not. Will have to experiment later with the customer use case what happens if I remove all that. Maybe adding it was a mistake, as misinterpretation of what was going on. Change-Id: I252e1233cae1622099bc3310814132dae58b2aed (cherry picked from commit 9c50273a9f3a15d1ff7ea4880638ca833570e0bd) Reviewed-on: https://gerrit.libreoffice.org/79250 Reviewed-by: Tor Lillqvist <t...@collabora.com> Tested-by: Tor Lillqvist <t...@collabora.com> diff --git a/extensions/source/ole/unoobjw.cxx b/extensions/source/ole/unoobjw.cxx index f868e87bf0c2..8476bcc348ba 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 35d53044cf12..b05218f1d5e4 100644 --- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx +++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx @@ -471,9 +471,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 ) ); } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits