From 1f6b2d52f222f14f85d378376236a0c1dcbc997e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 2 Sep 2015 07:33:52 +0200 Subject: [PATCH] Windows: Do not register "image/png" as clipboard format. As for some reason it causes paste into Gimp not to work. Make (QWindowsMimeImage:CF_PNG a statically accessible member and use that as entry into the hash. Task-number: QTBUG-46848 Change-Id: I8cf159c67742a6a94dd4f7b4670f447d466447ca --- src/plugins/platforms/windows/qwindowsmime.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowsmime.cpp b/src/plugins/platforms/windows/qwindowsmime.cpp index 375a7f1..862edea 100644 --- a/src/plugins/platforms/windows/qwindowsmime.cpp +++ b/src/plugins/platforms/windows/qwindowsmime.cpp @@ -1037,11 +1037,15 @@ public: bool canConvertToMime(const QString &mimeType, IDataObject *pDataObj) const; QVariant convertToMime(const QString &mime, IDataObject *pDataObj, QVariant::Type preferredType) const; QString mimeForFormat(const FORMATETC &formatetc) const; + + static UINT cfPng() { return CF_PNG; } private: bool hasOriginalDIBV5(IDataObject *pDataObj) const; - UINT CF_PNG; + static UINT CF_PNG; }; +UINT QWindowsMimeImage::CF_PNG = 0; + QWindowsMimeImage::QWindowsMimeImage() { CF_PNG = RegisterClipboardFormat(L"PNG"); @@ -1382,10 +1386,15 @@ QVector QLastResortMimes::formatsForMime(const QString &mimeType, con formatetcs += setCf(formats.key(mimeType)); } else if (!excludeList.contains(mimeType, Qt::CaseInsensitive)){ // register any other available formats - int cf = QWindowsMime::registerMimeType(mimeType); QLastResortMimes *that = const_cast(this); - that->formats.insert(cf, mimeType); - formatetcs += setCf(cf); + if (mimeType == QLatin1String("image/png")) { + // QTBUG-46848, pasting into GIMP does not work when registering "image/png". + that->formats.insert(QWindowsMimeImage::cfPng(), mimeType); + } else { + const int cf = QWindowsMime::registerMimeType(mimeType); + that->formats.insert(cf, mimeType); + formatetcs += setCf(cf); + } } if (!formatetcs.isEmpty()) qCDebug(lcQpaMime) << __FUNCTION__ << mimeType << formatetcs; -- 2.5.0.windows.1