[Libreoffice-commits] core.git: Branch 'feature/fixes36' - dtrans/source
Tomaž Vajngerl
tomaz.vajngerl at collabora.co.uk
Tue Nov 15 15:25:40 UTC 2016
dtrans/source/win32/dtobj/XTDataObject.cxx | 27 +++++++++++++++++++++++++++
dtrans/source/win32/dtobj/XTDataObject.hxx | 3 ++-
2 files changed, 29 insertions(+), 1 deletion(-)
New commits:
commit 5e2cc924ef24c6977efbd576971c94a951e38ed4
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Tue Nov 15 15:36:20 2016 +0100
tdf#103852 avoid clipboard deadlock
Change-Id: If0c5f01d0aefd2444781612d47d8145b4869f3a1
diff --git a/dtrans/source/win32/dtobj/XTDataObject.cxx b/dtrans/source/win32/dtobj/XTDataObject.cxx
index 51108a1..ad1c9f0 100644
--- a/dtrans/source/win32/dtobj/XTDataObject.cxx
+++ b/dtrans/source/win32/dtobj/XTDataObject.cxx
@@ -25,8 +25,11 @@
#include "DTransHelper.hxx"
#include "TxtCnvtHlp.hxx"
#include <com/sun/star/datatransfer/clipboard/XClipboardEx.hpp>
+#include "com/sun/star/awt/AsyncCallback.hpp"
+#include "com/sun/star/awt/XCallback.hpp"
#include "FmtFilter.hxx"
#include <comphelper/processfactory.hxx>
+#include <cppuhelper/implbase.hxx>
#if defined _MSC_VER
#pragma warning(push,1)
@@ -52,6 +55,22 @@ using namespace com::sun::star::datatransfer::clipboard;
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
+
+class AsyncDereference : public cppu::WeakImplHelper<css::awt::XCallback>
+{
+ Reference<XTransferable> maTransferable;
+public:
+ AsyncDereference(css::uno::Reference<css::datatransfer::XTransferable> const & rTransferable)
+ : maTransferable(rTransferable)
+ {}
+
+ virtual void SAL_CALL notify(css::uno::Any const &)
+ throw (css::uno::RuntimeException, std::exception) override
+ {
+ maTransferable.set(nullptr);
+ }
+};
+
// a helper class that will be thrown by the function validateFormatEtc
class CInvalidFormatEtcException
@@ -67,12 +86,20 @@ CXTDataObject::CXTDataObject( const Reference< XComponentContext >& rxContext,
const Reference< XTransferable >& aXTransferable )
: m_nRefCnt( 0 )
, m_XTransferable( aXTransferable )
+ , m_XComponentContext( rxContext )
, m_bFormatEtcContainerInitialized( sal_False )
, m_DataFormatTranslator( rxContext )
, m_FormatRegistrar( rxContext, m_DataFormatTranslator )
{
}
+CXTDataObject::~CXTDataObject()
+{
+ css::awt::AsyncCallback::create(m_XComponentContext)->addCallback(
+ new AsyncDereference(m_XTransferable),
+ css::uno::Any());
+}
+
// IUnknown->QueryInterface
STDMETHODIMP CXTDataObject::QueryInterface( REFIID iid, LPVOID* ppvObject )
diff --git a/dtrans/source/win32/dtobj/XTDataObject.hxx b/dtrans/source/win32/dtobj/XTDataObject.hxx
index 3d8d71c..f9e98e8 100644
--- a/dtrans/source/win32/dtobj/XTDataObject.hxx
+++ b/dtrans/source/win32/dtobj/XTDataObject.hxx
@@ -64,7 +64,7 @@ class CXTDataObject : public IDataObject
public:
CXTDataObject( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
const css::uno::Reference< css::datatransfer::XTransferable >& aXTransferable );
- virtual ~CXTDataObject() {}
+ virtual ~CXTDataObject();
// ole interface implementation
@@ -118,6 +118,7 @@ private:
private:
LONG m_nRefCnt;
css::uno::Reference< css::datatransfer::XTransferable > m_XTransferable;
+ css::uno::Reference< css::uno::XComponentContext> m_XComponentContext;
CFormatEtcContainer m_FormatEtcContainer;
sal_Bool m_bFormatEtcContainerInitialized;
CDataFormatTranslator m_DataFormatTranslator;
More information about the Libreoffice-commits
mailing list