OSDN Git Service

fix DnD retrieval of some image formats
authorIvailo Monev <xakepa10@gmail.com>
Tue, 29 Aug 2023 15:48:34 +0000 (18:48 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Tue, 29 Aug 2023 15:48:34 +0000 (18:48 +0300)
with the introduction of QImageWriter::formatForMimeType() and the related
QImageReader and QImageWriter methods the assumption that the image format
(plugin name) equals everything after the slash can be dismissed and
properly handled

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
src/gui/kernel/qdnd.cpp
src/gui/kernel/qdnd_x11.cpp

index caa7c7a..da3a4b9 100644 (file)
@@ -336,7 +336,7 @@ bool QInternalMimeData::hasFormatHelper(const QString &mimeType, const QMimeData
 
     bool foundFormat = data->hasFormat(mimeType);
     if (!foundFormat) {
-        QStringList imageFormats = imageWriteMimeFormats();
+        const QStringList imageFormats = imageWriteMimeFormats();
         if (mimeType == QLatin1String("application/x-qt-image")) {
             // check all supported image formats
             foreach (const QString &it, imageFormats) {
index 0f6064a..f3d76c5 100644 (file)
@@ -1963,7 +1963,7 @@ QVariant QDropData::retrieveData_sys(const QString &mimetype, QVariant::Type req
             QImage image = qvariant_cast<QImage>(o->data->imageData());
             QBuffer buf(&result);
             buf.open(QBuffer::WriteOnly);
-            image.save(&buf, mimetype.mid(mimetype.indexOf(QLatin1Char('/')) + 1).toLatin1().toUpper());
+            image.save(&buf, QImageWriter::formatForMimeType(mimetype.toLatin1()));
         }
         return result;
     }