summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-05-27 10:47:53 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-05-27 18:12:14 +0200
commit336f893c57c3c0281d4899629ad55603837d5d40 (patch)
tree1ecec74dfe9e1fe04ec27c5ac2bd581546590004 /sw/source
parentea9030461df4610225376301a72cf0cd7ea631e8 (diff)
tdf#107976 sw: let a view handle multiple transferables
Otherwise only the last transferable gets unregistered on closing the view, which means a use-after-free when trying to paste something copied from a closed document. Change-Id: I65594e07fa4fefe7ae51a12455b755d64700a00d Reviewed-on: https://gerrit.libreoffice.org/38088 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/uibase/inc/uivwimp.hxx2
-rw-r--r--sw/source/uibase/uiview/uivwimp.cxx21
2 files changed, 13 insertions, 10 deletions
diff --git a/sw/source/uibase/inc/uivwimp.hxx b/sw/source/uibase/inc/uivwimp.hxx
index 411e95e2e228..80209b9e8afa 100644
--- a/sw/source/uibase/inc/uivwimp.hxx
+++ b/sw/source/uibase/inc/uivwimp.hxx
@@ -88,7 +88,7 @@ class SwView_Impl
{
css::uno::Reference< css::frame::XDispatchProviderInterceptor > xDisProvInterceptor;
css::uno::Reference< css::view::XSelectionSupplier > mxXTextView; // UNO object
- css::uno::WeakReference< css::lang::XUnoTunnel > xTransferable;
+ std::vector< css::uno::WeakReference< css::lang::XUnoTunnel > > mxTransferables;
// temporary document for printing text of selection / multi selection
// in PDF export.
diff --git a/sw/source/uibase/uiview/uivwimp.cxx b/sw/source/uibase/uiview/uivwimp.cxx
index 8b6818ccd7ca..01a123e02f97 100644
--- a/sw/source/uibase/uiview/uivwimp.cxx
+++ b/sw/source/uibase/uiview/uivwimp.cxx
@@ -208,15 +208,18 @@ void SwView_Impl::AddClipboardListener()
void SwView_Impl::Invalidate()
{
GetUNOObject_Impl()->Invalidate();
- Reference< XUnoTunnel > xTunnel(xTransferable.get(), UNO_QUERY);
- if(xTunnel.is())
-
+ for (const auto& xTransferable: mxTransferables)
{
- SwTransferable* pTransferable = reinterpret_cast< SwTransferable * >(
- sal::static_int_cast< sal_IntPtr >(
- xTunnel->getSomething(SwTransferable::getUnoTunnelId())));
- if(pTransferable)
- pTransferable->Invalidate();
+ Reference< XUnoTunnel > xTunnel(xTransferable.get(), UNO_QUERY);
+ if(xTunnel.is())
+
+ {
+ SwTransferable* pTransferable = reinterpret_cast< SwTransferable * >(
+ sal::static_int_cast< sal_IntPtr >(
+ xTunnel->getSomething(SwTransferable::getUnoTunnelId())));
+ if(pTransferable)
+ pTransferable->Invalidate();
+ }
}
}
@@ -225,7 +228,7 @@ void SwView_Impl::AddTransferable(SwTransferable& rTransferable)
//prevent removing of the non-referenced SwTransferable
rTransferable.m_refCount++;
{
- xTransferable = Reference<XUnoTunnel> (&rTransferable);
+ mxTransferables.push_back(uno::WeakReference<lang::XUnoTunnel>(uno::Reference<lang::XUnoTunnel>(&rTransferable)));
}
rTransferable.m_refCount--;
}