tdf#141097 Revert "Veto process exit while an OLE client is connected"

This reverts changes that were made to prevent process exit when an
OLE client is connected. These commits had the side effect of preventing
the use case of creating a document via OLE, and then allowing
the user to view/edit and ultimately quit from the GUI.

Revert "More hacks for quit requests from an OLE Automation client"

This reverts commit 05e03911cd.

Revert "Veto process exit while an OLE client is connected"

This reverts commit 89f883bd90.

Change-Id: I29a1e42a830815bc8d1ff0056c22d86b8f98cc1a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118596
Tested-by: Jenkins
Reviewed-by: Tor Lillqvist <tml@collabora.com>
This commit is contained in:
Michael Warner
2021-08-20 11:43:06 +02:00
committed by Julien Nabet
parent e367e59e37
commit 080e455025
5 changed files with 1 additions and 89 deletions
+1 -8
View File
@@ -24,10 +24,7 @@
#include <comphelper/asyncquithandler.hxx>
#include <comphelper/processfactory.hxx>
AsyncQuitHandler::AsyncQuitHandler()
: mbForceQuit(false)
{
}
AsyncQuitHandler::AsyncQuitHandler() {}
AsyncQuitHandler& AsyncQuitHandler::instance()
{
@@ -42,10 +39,6 @@ void AsyncQuitHandler::QuitApplication()
xDesktop->terminate();
}
void AsyncQuitHandler::SetForceQuit() { mbForceQuit = true; }
bool AsyncQuitHandler::IsForceQuit() const { return mbForceQuit; }
IMPL_STATIC_LINK_NOARG(AsyncQuitHandler, OnAsyncQuit, void*, void) { QuitApplication(); }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-1
View File
@@ -35,7 +35,6 @@ $(eval $(call gb_Library_use_libraries,oleautobridge,\
cppuhelper \
cppu \
sal \
tl \
))
$(eval $(call gb_Library_use_system_win32_libs,oleautobridge,\
-68
View File
@@ -57,13 +57,9 @@
#include <salhelper/simplereferenceobject.hxx>
#include <rtl/ref.hxx>
#include <rtl/ustring.hxx>
#include <tools/diagnose_ex.h>
#include <sal/log.hxx>
#include <com/sun/star/beans/MethodConcept.hpp>
#include <com/sun/star/beans/PropertyConcept.hpp>
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/frame/TerminationVetoException.hpp>
#include <com/sun/star/frame/XTerminateListener.hpp>
#include <com/sun/star/lang/NoSuchMethodException.hpp>
#include <com/sun/star/script/CannotConvertException.hpp>
#include <com/sun/star/script/FailReason.hpp>
@@ -86,7 +82,6 @@
#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>
@@ -117,64 +112,6 @@ static bool writeBackOutParameter(VARIANTARG* pDest, VARIANT* pSource);
static bool writeBackOutParameter2( VARIANTARG* pDest, VARIANT* pSource);
static HRESULT mapCannotConvertException(const CannotConvertException &e, unsigned int * puArgErr);
namespace {
class TerminationVetoer : public WeakImplHelper<css::frame::XTerminateListener>
{
public:
int mnCount;
private:
TerminationVetoer()
: mnCount(0)
{
try
{
Reference< css::frame::XDesktop > xDesktop =
css::frame::Desktop::create( comphelper::getProcessComponentContext() );
xDesktop->addTerminateListener( this );
}
catch ( const Exception& )
{
DBG_UNHANDLED_EXCEPTION("extensions.olebridge");
}
}
public:
static rtl::Reference< TerminationVetoer > get()
{
static rtl::Reference< TerminationVetoer > aInstance( new TerminationVetoer );
return aInstance;
}
// XTerminateListener
void SAL_CALL queryTermination( const EventObject& ) override
{
SAL_INFO("extensions.olebridge", "TerminationVetoer::queryTermination: count=" << mnCount);
// 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();
}
}
void SAL_CALL notifyTermination( const EventObject& ) override
{
// ???
}
// XEventListener
void SAL_CALL disposing( const css::lang::EventObject& ) override
{
// ???
}
};
}
/* Does not throw any exceptions.
Param pInfo can be NULL.
*/
@@ -193,8 +130,6 @@ InterfaceOleWrapper::InterfaceOleWrapper( Reference<XMultiServiceFactory> const
UnoConversionUtilities<InterfaceOleWrapper>( xFactory, unoWrapperClass, comWrapperClass),
m_defaultValueType( 0)
{
TerminationVetoer::get()->mnCount++;
SAL_INFO("extensions.olebridge", "InterfaceOleWrapper CTOR, count=" << TerminationVetoer::get()->mnCount);
}
InterfaceOleWrapper::~InterfaceOleWrapper()
@@ -204,9 +139,6 @@ InterfaceOleWrapper::~InterfaceOleWrapper()
auto it = UnoObjToWrapperMap.find( reinterpret_cast<sal_uIntPtr>(m_xOrigin.get()));
if(it != UnoObjToWrapperMap.end())
UnoObjToWrapperMap.erase(it);
TerminationVetoer::get()->mnCount--;
SAL_INFO("extensions.olebridge", "InterfaceOleWrapper DTOR, count=" << TerminationVetoer::get()->mnCount);
}
COM_DECLSPEC_NOTHROW STDMETHODIMP InterfaceOleWrapper::QueryInterface(REFIID riid, void ** ppv)
-8
View File
@@ -29,8 +29,6 @@ class COMPHELPER_DLLPUBLIC AsyncQuitHandler
{
AsyncQuitHandler();
bool mbForceQuit;
public:
AsyncQuitHandler(const AsyncQuitHandler&) = delete;
const AsyncQuitHandler& operator=(const AsyncQuitHandler&) = delete;
@@ -38,12 +36,6 @@ public:
static AsyncQuitHandler& instance();
static void QuitApplication();
// 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();
bool IsForceQuit() const;
DECL_STATIC_LINK(AsyncQuitHandler, OnAsyncQuit, void*, void);
};
@@ -471,13 +471,9 @@ void VbaApplicationBase::Quit()
{
// This is the case of a call from an (OLE) Automation client.
// When an Automation client itself asks the process 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 ) );
}
}