QWidgetTextControl: deal with empty formats list properly

Do not call first on it. A regression was introduced by
56f0ebfe860e440dcbba8997f44836debc901119.

Fixes: QTBUG-110070
Change-Id: I7c969da889b6c7ad3a67149fe99ca47830683073
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
(cherry picked from commit 0cd153b2681437b91f07315a27238446cc24363f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Timur Pocheptsov 2023-01-12 10:44:34 +01:00 committed by Qt Cherry-pick Bot
parent 9bbf761373
commit 5da2292bff

View File

@ -2699,7 +2699,8 @@ void QWidgetTextControl::insertFromMimeData(const QMimeData *source)
bool hasData = false;
QTextDocumentFragment fragment;
#if QT_CONFIG(textmarkdownreader)
if (source->formats().first() == "text/markdown"_L1) {
const auto formats = source->formats();
if (formats.size() && formats.first() == "text/markdown"_L1) {
auto s = QString::fromUtf8(source->data("text/markdown"_L1));
fragment = QTextDocumentFragment::fromMarkdown(s);
hasData = true;