From f91531a056740c2e3a9b2ead8cd6c3456d7cb99f Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 17 Sep 2020 13:27:54 +0200 Subject: Fix a bug when streaming QVariants containing a QRegExp Fix a logic error. QRegExp is a UserType in Qt 6 and we need to check for it in the right place. Fixes an autotest failure in the qregexp autotest in qt5compat. Change-Id: I454cfcfd12b36f756b24b69a5412455db9dccbe7 Reviewed-by: Karsten Heimrich --- src/corelib/kernel/qvariant.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/corelib/kernel/qvariant.cpp') diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 65cdfc8580..efc90595bf 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -1248,6 +1248,9 @@ void QVariant::save(QDataStream &s) const // map to Qt 5 values if (typeId == QMetaType::User) { typeId = Qt5UserType; + if (!strcmp(d.type().name(), "QRegExp")) { + typeId = 27; // QRegExp in Qt 4/5 + } } else if (typeId > Qt5LastCoreType && typeId <= QMetaType::LastCoreType) { // the type didn't exist in Qt 5 typeId = Qt5UserType; @@ -1260,10 +1263,6 @@ void QVariant::save(QDataStream &s) const } } else if (typeId == QMetaType::QSizePolicy) { typeId = Qt5SizePolicy; - } else if (saveAsUserType) { - if (!strcmp(d.type().name(), "QRegExp")) { - typeId = 27; // QRegExp in Qt 4/5 - } } } if (s.version() < QDataStream::Qt_4_0) { -- cgit v1.2.3