diff options
author | Nicolas Werner <nicolas.werner@hotmail.de> | 2022-03-21 23:15:09 +0100 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2022-03-21 23:15:09 +0100 |
commit | e52f90a9418156ad958d515e056f508c45f1bbee (patch) | |
tree | cec1060e3d2b3ab43f34fb5b04fd622e89c632ab | |
parent | Fix potential crash if there is no image format pasted (diff) | |
download | nheko-e52f90a9418156ad958d515e056f508c45f1bbee.tar.xz |
Properly fix image uploads without image/* format
-rw-r--r-- | src/timeline/InputBar.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/timeline/InputBar.cpp b/src/timeline/InputBar.cpp index bf8f926a..2d29dbbd 100644 --- a/src/timeline/InputBar.cpp +++ b/src/timeline/InputBar.cpp @@ -155,9 +155,16 @@ InputBar::insertMimeData(const QMimeData *md) if (md->hasImage()) { if (formats.contains(QStringLiteral("image/svg+xml"), Qt::CaseInsensitive)) { startUploadFromMimeData(*md, QStringLiteral("image/svg+xml")); - } else if (formats.contains(QStringLiteral("image/png"), Qt::CaseInsensitive) || - formats.empty()) { + } else if (formats.contains(QStringLiteral("image/png"), Qt::CaseInsensitive)) { startUploadFromMimeData(*md, QStringLiteral("image/png")); + } else if (image.empty()) { + QByteArray ba; + QBuffer buffer(&ba); + buffer.open(QIODevice::WriteOnly); + qvariant_cast<QImage>(md->imageData()).save(&buffer, "PNG"); + QMimeData d; + d.setData(QStringLiteral("image/png"), ba); + startUploadFromMimeData(d, image.first()); } else { startUploadFromMimeData(*md, image.first()); } |