Ticket #22552: qt-everywhere-src-6.10.1-upstream_fixes-1.patch

File qt-everywhere-src-6.10.1-upstream_fixes-1.patch, 9.2 KB (added by zeckma, 10 months ago)
  • qtdeclarative/src/qml/jsruntime/qv4lookup_p.h

    From 9c6b2b78e9076f1c2676aa0c41573db9ca480654 Mon Sep 17 00:00:00 2001
    From: Ulf Hermann <ulf.hermann@qt.io>
    Date: Tue, 2 Dec 2025 17:42:30 +0100
    Subject: QtQml: Invalidate fallback lookups after each call from AOT code
    
    Fallback property lookups are created for completely dynamic
    metaobjects. Anything about them may change between any two calls.
    
    Pick-to: 6.8 6.5
    Fixes: QTBUG-142331
    Change-Id: Ib732c37a6f27ab8105bea0eeae000af7eb9c36d7
    Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
    (cherry picked from commit 9af6d2d6d0046b3c8369e15eb4791957cdc7ab7b)
    Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
    ---
     qtdeclarative/src/qml/jsruntime/qv4lookup_p.h                    |  4 ++
     qtdeclarative/src/qml/qml/qqml.cpp                               | 13 +++++--
     qtdeclarative/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt   |  2 +
     qtdeclarative/tests/auto/qml/qmlcppcodegen/data/propertyMap.qml  |  6 +++
     qtdeclarative/tests/auto/qml/qmlcppcodegen/data/propertymap.h    | 40 ++++++++++++++++++++
     qtdeclarative/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 43 ++++++++++++++++++++++
     6 files changed, 104 insertions(+), 4 deletions(-)
     create mode 100644 qtdeclarative/tests/auto/qml/qmlcppcodegen/data/propertyMap.qml
     create mode 100644 qtdeclarative/tests/auto/qml/qmlcppcodegen/data/propertymap.h
    
    diff --git a/qtdeclarative/src/qml/jsruntime/qv4lookup_p.h b/qtdeclarative/src/qml/jsruntime/qv4lookup_p.h
    index 083c3ec2df..ef36bf67c5 100644
    a b struct Q_QML_EXPORT Lookup {  
    159159            const QQmlPropertyData *propertyData;
    160160        } qobjectMethodLookup;
    161161        struct {
     162            // NB: None of this is actually cache-able. The metaobject may change at any time.
     163            //     We invalidate this data every time the lookup is invoked and thereby force a
     164            //     re-initialization next time.
     165
    162166            quintptr isConstant; // This is a bool, encoded as 0 or 1. Both values are ignored by gc
    163167            quintptr metaObject; // a (const QMetaObject* & 1) or nullptr
    164168            int coreIndex;
  • qtdeclarative/src/qml/qml/qqml.cpp

    diff --git a/qtdeclarative/src/qml/qml/qqml.cpp b/qtdeclarative/src/qml/qml/qqml.cpp
    index 4e3b4fcf1e..3f0d9e332b 100644
    a b struct FallbackPropertyQmlData  
    13861386
    13871387static FallbackPropertyQmlData findFallbackPropertyQmlData(QV4::Lookup *lookup, QObject *object)
    13881388{
     1389    // We've just initialized the lookup. So everything must be fine here.
     1390
    13891391    QQmlData *qmlData = QQmlData::get(object);
    1390     if (qmlData && qmlData->isQueuedForDeletion)
    1391         return {qmlData, nullptr, PropertyResult::Deleted};
    13921392
     1393    Q_ASSERT(!qmlData || !qmlData->isQueuedForDeletion);
    13931394    Q_ASSERT(!QQmlData::wasDeleted(object));
    13941395
    13951396    const QMetaObject *metaObject
    13961397            = reinterpret_cast<const QMetaObject *>(lookup->qobjectFallbackLookup.metaObject - 1);
    1397     if (!metaObject || metaObject != object->metaObject())
    1398         return {qmlData, nullptr, PropertyResult::NeedsInit};
     1398    Q_ASSERT(metaObject == object->metaObject());
    13991399
    14001400    return {qmlData, metaObject, PropertyResult::OK};
    14011401}
    … … bool AOTCompiledContext::loadScopeObjectPropertyLookup(uint index, void *target)  
    25852585        break;
    25862586    case QV4::Lookup::Call::ContextGetterScopeObjectPropertyFallback:
    25872587        result = loadFallbackProperty(lookup, qmlScopeObject, target, this);
     2588        lookup->call = QV4::Lookup::Call::ContextGetterGeneric;
    25882589        break;
    25892590    default:
    25902591        return false;
    … … bool AOTCompiledContext::writeBackScopeObjectPropertyLookup(uint index, void *so  
    26162617        break;
    26172618    case QV4::Lookup::Call::ContextGetterScopeObjectPropertyFallback:
    26182619        result = writeBackFallbackProperty(lookup, qmlScopeObject, source);
     2620        lookup->call = QV4::Lookup::Call::ContextGetterGeneric;
    26192621        break;
    26202622    default:
    26212623        return false;
    … … bool AOTCompiledContext::getObjectLookup(uint index, QObject *object, void *targ  
    28162818        result = lookup->asVariant
    28172819                ? loadFallbackAsVariant(lookup, object, target, this)
    28182820                : loadFallbackProperty(lookup, object, target, this);
     2821        lookup->call = QV4::Lookup::Call::GetterGeneric;
    28192822        break;
    28202823    default:
    28212824        return false;
    … … bool AOTCompiledContext::writeBackObjectLookup(uint index, QObject *object, void  
    28502853        result = lookup->asVariant
    28512854                ? writeBackFallbackAsVariant(lookup, object, source)
    28522855                : writeBackFallbackProperty(lookup, object, source);
     2856        lookup->call = QV4::Lookup::Call::GetterGeneric;
    28532857        break;
    28542858    default:
    28552859        return false;
    … … bool AOTCompiledContext::setObjectLookup(uint index, QObject *object, void *valu  
    30103014        result = lookup->asVariant
    30113015                ? storeFallbackAsVariant(engine->handle(), lookup, object, value)
    30123016                : storeFallbackProperty(lookup, object, value);
     3017        lookup->call = QV4::Lookup::Call::SetterGeneric;
    30133018        break;
    30143019    default:
    30153020        return false;
  • qtdeclarative/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt

    diff --git a/qtdeclarative/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt b/qtdeclarative/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt
    index 79e908c967..67cdefa30d 100644
    a b set(cpp_sources  
    2626    multiforeign.h
    2727    objectwithmethod.h
    2828    person.cpp person.h
     29    propertymap.h
    2930    qmlusing.h
    3031    recursiveObject.h
    3132    refuseWrite.h
    … … set(qml_files  
    282283    popContextAfterRet.qml
    283284    prefixedMetaType.qml
    284285    pressAndHoldButton.qml
     286    propertyMap.qml
    285287    qmlUsing.qml
    286288    qtbug113150.qml
    287289    qtfont.qml
  • new file qtdeclarative/tests/auto/qml/qmlcppcodegen/data/propertyMap.qml

    diff --git a/qtdeclarative/tests/auto/qml/qmlcppcodegen/data/propertyMap.qml b/qtdeclarative/tests/auto/qml/qmlcppcodegen/data/propertyMap.qml
    new file mode 100644
    index 0000000000..c00f3972e8
    - +  
     1pragma Strict
     2import TestTypes
     3
     4WithPropertyMap {
     5    objectName: map.foo
     6}
  • new file qtdeclarative/tests/auto/qml/qmlcppcodegen/data/propertymap.h

    diff --git a/qtdeclarative/tests/auto/qml/qmlcppcodegen/data/propertymap.h b/qtdeclarative/tests/auto/qml/qmlcppcodegen/data/propertymap.h
    new file mode 100644
    index 0000000000..64d84c5c09
    - +  
     1// Copyright (C) 2025 The Qt Company Ltd.
     2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
     3
     4#ifndef PROPERTYMAP_H
     5#define PROPERTYMAP_H
     6
     7#include <QtCore/qobject.h>
     8#include <QtQml/qqml.h>
     9#include <QtQml/qqmlpropertymap.h>
     10
     11class WithPropertyMap : public QObject
     12{
     13    Q_OBJECT
     14    QML_ELEMENT
     15    Q_PROPERTY(QQmlPropertyMap *map READ map NOTIFY mapChanged)
     16public:
     17    WithPropertyMap(QObject *parent = nullptr)
     18        : QObject(parent)
     19        , m_map(new QQmlPropertyMap(this))
     20    {
     21    }
     22
     23    QQmlPropertyMap *map() const { return m_map; }
     24
     25    void setProperties(const QVariantHash &properties)
     26    {
     27        delete m_map;
     28        m_map = new QQmlPropertyMap(this);
     29        m_map->insert(properties);
     30        emit mapChanged();
     31    }
     32
     33signals:
     34    void mapChanged();
     35
     36private:
     37    QQmlPropertyMap *m_map = nullptr;
     38};
     39
     40#endif // PROPERTYMAP_H
  • qtdeclarative/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp

    diff --git a/qtdeclarative/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/qtdeclarative/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
    index 70c50b457a..a90e2a6050 100644
    a b  
    1010#include <data/getOptionalLookup.h>
    1111#include <data/listprovider.h>
    1212#include <data/objectwithmethod.h>
     13#include <data/propertymap.h>
    1314#include <data/qmlusing.h>
    1415#include <data/refuseWrite.h>
    1516#include <data/resettable.h>
    … … private slots:  
    237238    void parentProperty();
    238239    void popContextAfterRet();
    239240    void prefixedType();
     241    void propertyMap();
    240242    void propertyOfParent();
    241243    void qmlUsing();
    242244    void qtfont();
    … … void tst_QmlCppCodegen::prefixedType()  
    49084910    QCOMPARE(o->property("countH").toInt(), 11);
    49094911}
    49104912
     4913void tst_QmlCppCodegen::propertyMap()
     4914{
     4915    QQmlEngine engine;
     4916
     4917    const QUrl document(u"qrc:/qt/qml/TestTypes/propertyMap.qml"_s);
     4918    QQmlComponent c(&engine, document);
     4919    QVERIFY2(c.isReady(), qPrintable(c.errorString()));
     4920
     4921    QTest::ignoreMessage(
     4922            QtWarningMsg, qPrintable(
     4923                document.toString()
     4924                + u":5:5: QML WithPropertyMap: Unable to assign [undefined] to \"objectName\""));
     4925
     4926    QScopedPointer<QObject> o(c.create());
     4927    QVERIFY(o);
     4928
     4929    WithPropertyMap *w = qobject_cast<WithPropertyMap *>(o.data());
     4930    QVERIFY(w);
     4931
     4932    QVERIFY(w->objectName().isEmpty());
     4933
     4934    w->setProperties({
     4935        { u"foo"_s, u"aaa"_s },
     4936        { u"bar"_s, u"bbb"_s },
     4937    });
     4938
     4939    QCOMPARE(w->objectName(), u"aaa"_s);
     4940
     4941    w->setProperties({
     4942        { u"foo"_s, u"ccc"_s },
     4943    });
     4944
     4945    QCOMPARE(w->objectName(), u"ccc"_s);
     4946
     4947    w->setProperties({
     4948        { u"foo"_s, 24.25 },
     4949    });
     4950
     4951    QCOMPARE(w->objectName(), u"24.25"_s);
     4952}
     4953
    49114954void tst_QmlCppCodegen::propertyOfParent()
    49124955{
    49134956    QQmlEngine engine;