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>
This commit is contained in:
parent
c9ad5ad3b7
commit
68f097923f
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user