QMimeData: return null string for null byte array

This amends 589a01ff6b. And this is
not needed for Qt 6 due to QTextCodec was replaced by QStringConverter.

Fixes: QTBUG-84662
Change-Id: I810072108e5f843d7f8cf02b5f4c6f4ba6be0a4e
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Liang Qi 2020-08-03 21:30:34 +02:00
parent 0c8c20e827
commit 5826a7ad92

View File

@ -160,6 +160,8 @@ QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QMetaType::T
#if QT_CONFIG(textcodec)
case QMetaType::QString: {
const QByteArray ba = data.toByteArray();
if (ba.isNull())
return QString();
QTextCodec *codec = QTextCodec::codecForName("utf-8");
if (format == QLatin1String("text/html"))
codec = QTextCodec::codecForHtml(ba, codec);