diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-06-10 11:26:31 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-08-13 08:48:32 +0200 |
commit | 048debe8f9a99bfd5db44b48657c4e1bc28c3448 (patch) | |
tree | 883b318fe4ba0bc99af320554d241cba66c8cfd6 /src/gui/kernel/qguivariant.cpp | |
parent | 4a69cd7f72140c8f4c83f986b3366f7bd9ba69a3 (diff) |
Restrict QVariant::isNull() behavior
isNull() would forward to the contained type and check that type's
isNull() method for some of the builtin types. Remove that behavior
and only return true in isNull(), if the variant is invalid, doesn't
contain data or contains a null pointer.
In addition, implement more consistent behavior when constructing
a QVariant using the internal API taking a copy from a void *.
isNull() should return true in both cases. This mainly changes behavior
for some corner cases and when using our internal API.
[ChangeLog][Important Behavior Changes] QVariant::isNull()
no longer returns true when the variant contains an object of some
type with an isNull() method, that returns true for the object;
QVariant::isNull() now only returns true when the variant contains
no object or a null pointer.
Change-Id: I3125041c4f8f8618a04aa375aa0a56b19c02dcf5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/gui/kernel/qguivariant.cpp')
-rw-r--r-- | src/gui/kernel/qguivariant.cpp | 21 |
1 files changed, 0 insertions, 21 deletions
diff --git a/src/gui/kernel/qguivariant.cpp b/src/gui/kernel/qguivariant.cpp index efd98f691d..fbcf6494b4 100644 --- a/src/gui/kernel/qguivariant.cpp +++ b/src/gui/kernel/qguivariant.cpp @@ -101,26 +101,6 @@ struct GuiTypesFilter { }; }; -// This class is a hack that customizes access to QPolygon and QPolygonF -template<class Filter> -class QGuiVariantIsNull : public QVariantIsNull<Filter> { - typedef QVariantIsNull<Filter> Base; -public: - QGuiVariantIsNull(const QVariant::Private *d) - : QVariantIsNull<Filter>(d) - {} - template<typename T> - bool delegate(const T *p) { return Base::delegate(p); } - bool delegate(const QPolygon*) { return v_cast<QPolygon>(Base::m_d)->isEmpty(); } - bool delegate(const QPolygonF*) { return v_cast<QPolygonF>(Base::m_d)->isEmpty(); } - bool delegate(const void *p) { return Base::delegate(p); } -}; -static bool isNull(const QVariant::Private *d) -{ - QGuiVariantIsNull<GuiTypesFilter> isNull(d); - return QMetaTypeSwitcher::switcher<bool>(isNull, d->type().id(), nullptr); -} - static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) { @@ -263,7 +243,6 @@ static void streamDebug(QDebug dbg, const QVariant &v) #endif const QVariant::Handler qt_gui_variant_handler = { - isNull, convert, #if !defined(QT_NO_DEBUG_STREAM) streamDebug |