diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-11-01 13:58:11 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-11-07 09:30:42 +0100 |
commit | 68f097923f429861d7148236b48c90ebb7729fee (patch) | |
tree | 7902d0e928f3c3cb3750e906d1b0351bba091df9 | |
parent | c9ad5ad3b73ff60e9a40173b1ae49e67800a4b72 (diff) |
Fix registration of Windows-specific custom mime types
Data received by Qt from a native clipboard- or drag'n'drop-source is
mapped to a application/x-qt-windows-mime;value=... mime type, where the
"value" corresponds to the native clipboard format name, e.g.
"FileGroupDescriptor". When we register such a mime type in Qt, then we
need to get the same clipboard format number back. I.e. registering
'application/x-qt-windows-mime;value="FileGroupDescriptor"' needs to
produce the same Windows clipboard format identifier as the call to
RegisterClipboardFormat("FileGroupDescriptor").
Otherwise, a mime converter implementation has to operate on different
clipboard format values in the implementations of the different virtual
functions that are operating on FORMATETC data structures.
Task-number: QTBUG-93632
Change-Id: I0b7e3a2fc0e3f72bffc4490fc0ff4b190e0929a3
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
-rw-r--r-- | src/plugins/platforms/windows/qwindowsmimeregistry.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/plugins/platforms/windows/qwindowsmimeregistry.cpp b/src/plugins/platforms/windows/qwindowsmimeregistry.cpp index b2f9e4289d..55d0266bb2 100644 --- a/src/plugins/platforms/windows/qwindowsmimeregistry.cpp +++ b/src/plugins/platforms/windows/qwindowsmimeregistry.cpp @@ -1496,12 +1496,18 @@ void QWindowsMimeRegistry::registerMime(QWindowsMime *mime) /*! Registers the MIME type \a mime, and returns an ID number identifying the format on Windows. + + A mime type \c {application/x-qt-windows-mime;value="WindowsType"} will be + registered as the clipboard format for \c WindowsType. */ int QWindowsMimeRegistry::registerMimeType(const QString &mime) { - const UINT f = RegisterClipboardFormat(reinterpret_cast<const wchar_t *> (mime.utf16())); - if (!f) - qErrnoWarning("QWindowsApplication::registerMimeType: Failed to register clipboard format"); + const QString mimeType = isCustomMimeType(mime) ? customMimeType(mime) : mime; + const UINT f = RegisterClipboardFormat(reinterpret_cast<const wchar_t *> (mimeType.utf16())); + if (!f) { + qErrnoWarning("QWindowsMimeRegistry::registerMimeType: Failed to register clipboard format " + "for %s", qPrintable(mime)); + } return int(f); } |