Kaydet (Commit) 9286cebd authored tarafından Michael Stahl's avatar Michael Stahl

vcl: fix deadlock in VclGtkClipboard::setContents()

Must not call getTransferDataFlavors with m_Mutex held;

6  TransferableHelper::getTransferDataFlavors() (this=0x567b980) at svtools/source/misc/transfer.cxx:392
7  VclGtkClipboard::setContents(com::sun::star::uno::Reference<com::sun::star::datatransfer::XTransferable> const&, com::sun::star::uno::Reference<com::sun::star::datatransfer::clipboard::XClipboardOwner> const&) (this=0x3199550, xTrans=uno::Reference to (SwTransferable *) 0x567b9a8, xClipboardOwner=uno::Reference to (SwTransferable *) 0x567b9b0) at vcl/unx/gtk3_kde5/../gtk3/gtk3gtkinst.cxx:618
8  TransferableHelper::CopyToSelection(vcl::Window*) const (this=0x567b980, pWindow=0x301b0c0) at svtools/source/misc/transfer.cxx:960

CopyToSelection() uses SolarMutexReleaser, then getTransferDataFlavors()
has a SolarMutexGuard; this will deadlock against the main thread
that holds SolarMutex and calls VclGtkClipboard::setContents() itself,
from VclGtkClipboard::OwnerPossiblyChanged().

Change-Id: Ibda0b6bce6f3388c45cee8077dd977abb3dda366
Reviewed-on: https://gerrit.libreoffice.org/67121
Tested-by: Jenkins
Reviewed-by: 's avatarMichael Stahl <Michael.Stahl@cib.de>
üst b9afe593
...@@ -617,6 +617,12 @@ void VclGtkClipboard::setContents( ...@@ -617,6 +617,12 @@ void VclGtkClipboard::setContents(
const Reference< css::datatransfer::XTransferable >& xTrans, const Reference< css::datatransfer::XTransferable >& xTrans,
const Reference< css::datatransfer::clipboard::XClipboardOwner >& xClipboardOwner ) const Reference< css::datatransfer::clipboard::XClipboardOwner >& xClipboardOwner )
{ {
css::uno::Sequence<css::datatransfer::DataFlavor> aFormats;
if (xTrans.is())
{
aFormats = xTrans->getTransferDataFlavors();
}
osl::ClearableMutexGuard aGuard( m_aMutex ); osl::ClearableMutexGuard aGuard( m_aMutex );
Reference< datatransfer::clipboard::XClipboardOwner > xOldOwner( m_aOwner ); Reference< datatransfer::clipboard::XClipboardOwner > xOldOwner( m_aOwner );
Reference< datatransfer::XTransferable > xOldContents( m_aContents ); Reference< datatransfer::XTransferable > xOldContents( m_aContents );
...@@ -635,7 +641,6 @@ void VclGtkClipboard::setContents( ...@@ -635,7 +641,6 @@ void VclGtkClipboard::setContents(
assert(m_aGtkTargets.empty()); assert(m_aGtkTargets.empty());
if (m_aContents.is()) if (m_aContents.is())
{ {
css::uno::Sequence<css::datatransfer::DataFlavor> aFormats = xTrans->getTransferDataFlavors();
std::vector<GtkTargetEntry> aGtkTargets(m_aConversionHelper.FormatsToGtk(aFormats)); std::vector<GtkTargetEntry> aGtkTargets(m_aConversionHelper.FormatsToGtk(aFormats));
if (!aGtkTargets.empty()) if (!aGtkTargets.empty())
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment