From 9c855f5e596bf97cb1db6de3cc3d8f3785ec096b Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 3 Jan 2025 10:03:01 +0100 Subject: [PATCH] Filter out text/uri-list with empty list ...as seen at least with the Qt6 Wasm implementation (see the code comment for details), and where, at least when trying to paste some plain text into Writer, the LO code would then favor that faux text/uri-list over text/plain, and would get into the > else if( bMsg ) branch in SwTransferable::PasteFileList (sw/source/uibase/dochdl/swdtflvr.cxx) and try to synchronously show a message box, which for now causes an abort in the Emscripten build Change-Id: I64e7cf66717f29b3609c04aea3c6124279ab55de Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179699 Reviewed-by: Stephan Bergmann Tested-by: Jenkins --- vcl/qt5/QtTransferable.cxx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/vcl/qt5/QtTransferable.cxx b/vcl/qt5/QtTransferable.cxx index 16f24763cf6e..266e9b49c341 100644 --- a/vcl/qt5/QtTransferable.cxx +++ b/vcl/qt5/QtTransferable.cxx @@ -75,6 +75,19 @@ css::uno::Sequence SAL_CALL QtTransferable::getTr if (rMimeType == QStringLiteral("text/plain;charset=unicode")) continue; + // At least the Qt6 Wasm implementation may announce text/uri-list even though the actual + // list of URLs is empty (presumably since + // "wasm: + // implement async drag-and-drop" unconditionally calls setUrls in + // DataTransfer::toMimeDataWithFile's MimeContext::deref): + if (rMimeType == QStringLiteral("text/uri-list")) + { + if (m_pMimeData->urls().empty()) + { + continue; + } + } + // LO doesn't like 'text/plain', so we have to provide UTF-16 bool bIsNoCharset = false, bIsUTF16 = false, bIsUTF8 = false; if (lcl_textMimeInfo(toOUString(rMimeType), bIsNoCharset, bIsUTF16, bIsUTF8))