Commit Graph

46 Commits

Author SHA1 Message Date
Ulf Hermann 0351ad8c60 QQmlListModel: Invalidate ModelObject when necessary
Both the object and the listmodel may be deleted during the life time of
ModelObject. Don't crash when that happens.

Also, fix QV4QPointer to actually name the type of the pointer it
stores. Apparently this is the first time we add a QV4QPointer of
something that's not a plain QObject.

Pick-to: 5.15
Task-number: QTBUG-118024
Change-Id: I208d8749bcd67970f7bfbe569eed7a472f909508
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 90c55e859e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit aa253878fe)
(cherry picked from commit f7182e0124)
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
(cherry picked from commit ca5bd206d49fafb813c52570a89006ed1967b17c)
2024-08-12 16:45:59 +00:00
Ulf Hermann 749470e6b8 ListModel: Use PersistentValue to keep track of objects
This is the simplest way to prevent the garbage collector from
destroying the object while at the same time allowing a manual
destruction.

Task-number: QTBUG-95895
Task-number: QTBUG-96167
Fixes: QTBUG-91390
Change-Id: Ic3f3146bc555991068ce3367971e050f745d235d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 718f3469f6)
2023-01-31 10:35:38 +01:00
Mitch Curtis 5ae7066e84 Consolidate test helpers into private libraries
Previously each test would include and build sources from the shared
folder. Now we make those sources a library, build it once, then have
each test link to it instead.

We also take the opportunity to move some helpers that qtquickcontrols2
had added into the quicktestutils library where it makes sense, and
for the helpers that don't make sense to be there, move them into
quickcontrolstestutils.

We add the libraries to src/ so that they are internal modules built as
part of Qt, rather than tests. That way we can use them in a standalone
test outside of qtdeclarative.

Task-number: QTBUG-95621
Change-Id: I0a2ab3976fdbff2e4414df7bdc0808f16453b80a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit e310dadef7)
2021-09-14 12:13:57 +02:00
Ulf Hermann 7c6d9d8bf0 QQmlListModel: Don't return from the middle of a loop
We still have to process the other properties there.

Change-Id: I043596dc55de885e6b746020633ec8b97d043ff2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 75f957f87a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2021-09-13 15:22:37 +00:00
Jaeyoon Jung 784aad8fd0 QQmlListModel: Fix C++ owned object getting destroyed
If an object is explicitly set as C++ owned, it should not be turned to
destructible in any case. explicitIndestructibleSet flag is used for
that and thus it should not be unset in any case.
This fixes an issue where a C++ owned object could be destroyed by GC
when it is added to a ListModel. An object is supposed to be set as
destructible implicitly when it is used as a return value from JS unless
explicitIndestructibleSet is set.

Fixes: QTBUG-96167
Change-Id: Iad06847e56e29dd1b20146be108d7f747d8474dc
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Jaeyoon Jung <jaeyoon.jung@lge.com>
(cherry picked from commit 219ca3bf2b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2021-09-02 10:42:56 +00:00
Cathy Park b1f7d1380c qqmllistmodel: Fix QObjects setting indestructible
It makes a QObject indestructable only if its ownership is determined.
This fixes an issue where a QObject created by createObject() in QML
becomes indestructable once it is appended to a ListModel.

Fixes: QTBUG-95895
Change-Id: I30647298977d7901dab938626e8f94b9910c21e3
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Jaeyoon Jung <jaeyoon.jung@lge.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
(cherry picked from commit 69e07c55ad)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2021-08-26 09:33:04 +00:00
Fabian Kosmale 1d0ef3135f Treat substitution free template string literals as string bindings
Before this change, they were treated as script bindings, which are less
efficient, and could not be used in ListElement.

Fixes: QTBUG-95139
Change-Id: Ic66052c7f58b3ffdf1b7c0c169f42b4f99df62a1
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
(cherry picked from commit e8121d9300)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2021-07-23 17:53:48 +00:00
Fabian Kosmale 14e60183a9 ListModel: Fix accessing empty strings in ListElement
We store empty strings as null strings in StringOrTranslation;
consequently isSet will return false for such a string. However, we
still know that we are storing a string, and therefore need to return
a QVariant containing an empty string, instead of a null QVariant.
Amends 5022b91b31.

This fixes the "undefined" warning in Calqlatr (but changes nothing
about the fact that the example isn't reflective of modern QML
practices).

Task-number: QTBUG-54267
Change-Id: I83d871a79cd2bc0484f0eaf62d4ca345e39218aa
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
(cherry picked from commit 9be6a9327a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2021-06-30 15:09:14 +00:00
Ulf Hermann 695f6360d1 QQmlListModel: Guard QObject pointers in the list
If a QObject in the list is deleted from elsewhere, we need to zero it.

Amends commit 3edac1d0a70961e6f86564cc0a98339df6ac5964.

Fixes: QTBUG-94833
Change-Id: Ic33a5a0baa160824a34f353806dbfd876fa7123a
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
(cherry picked from commit b2ee7364be)
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-06-30 09:56:41 +02:00
Maximilian Goldstein d30fad2a71 qqmllistmodel: Fix QObjects getting garbage collected
Previously QObject's could get garbage collected while in use.
This change fixes this by making them indestructible while in use and then restoring their previous state.

[ChangeLog][QtQml][QQmlListModel][Important Behavior Changes] ListModels now take ownership of the objects added to them, only releasing them after the object has been removed again. This may break existing solutions which rely on the object not being owned by the model.

Fixes: QTBUG-91390
Change-Id: Ifd37c90e13fb0b6ad8a5a06e89f9fc9a429f6316
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
(cherry picked from commit 16fc4cf366)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2021-06-30 06:37:47 +00:00
Maximilian Goldstein c3860cd04b qqmlistmodel: Fix crash when modelCache is null
Fixes: QTBUG-89173
Pick-to: 5.15
Change-Id: Ife82518808fc5504ec42407e80ed3de89ed4adeb
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-12-08 09:46:04 +01:00
Fabian Kosmale bf547fb272 ListModel: support URLs
Fixes: QTBUG-88379
Change-Id: I6e2ea550d8f8972c5fdcdc21a5e3851992c591a5
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-11-12 10:23:12 +01:00
David Skoland e47edfe7a7 Update tests to use new metaType system
Change from the QVariant enum to the QMetaType enum and prefer typeId
over userType where possible

Change-Id: Ic89c55978d46cc23d23b8e9c82c475c0c220fae3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-11-02 14:56:00 +01:00
Fabian Kosmale 684f9df784 Long live QML inline components
[ChangeLog][QtQml] It is now possible to declare new QML components in
a QML file via the component keyword. They can be used just as if they
were declared in another file, with the only difference that the type
name needs to be prefixed with the name of the containing type outside
of the file were the inline component has been declared.

Notably, inline components are not closures: In the following
example, the output would be 42

// MyItem.qml
Item {
    property int i: 33
    component IC: Item {
        Component.onCompleted: console.log(i)
    }
}
// user.qml
Item {
    property int i: 42
    MyItem.IC {}
}

Fixes: QTBUG-79382
Change-Id: I6a5ffc43f093a76323f435cfee9bab217781b8f5
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-01-23 15:58:10 +01:00
Fabian Kosmale 6fceeab1d1 QML ListModel: Emit a warning when adding an object with undefined or null member
The current code in ListModel simply did a reset of an existing
property, in case a role existed and was set to null/undefined. If the
role did not exist, the code would simply skip over the member and do
nothing.
However, this does not make any sense for newly inserted items, and
most likely indicates a misunderstanding of how ListModel works.

Creating an undefined/null role does not really make sense, as those
could only ever store a undefined/null value.

Change-Id: I4c1361647a82146565eaffe064598c94c748b4f5
Task-number: QTBUG-63569
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-10-10 15:53:36 +02:00
Fabian Kosmale 8ea33db635 QQmlListModel: handle nested list models during iteration
ListElement::getProperty returns in turn a list model
The ModelObjectOwnPropertyKeyIterator should however return the concrete
values, and not some proxy object. This would cause funny return values
in the best case, and a crash in case of QTBUG-79083.

We therefore convert the nested model to a JavaScript array in
ModelObjectOwnPropertyKeyIterator::next, which avoids beforementioned
issues.

Fixes: QTBUG-79083
Change-Id: If038598ff1c3c59090e994aaba5fba94a6964224
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-08 13:26:44 +00:00
Ulf Hermann 325e6305b4 Move model types into their own library
The model types are not part of the core QML runtime and should only be
loaded if you explicitly import them. We cannot enforce that in Qt5 as
some of them are available from the QtQml import, but we can change it
in Qt6.

Change-Id: I1e49e84d748e352537ec2d4af901c034c91d038f
Reviewed-by: Erik Verbruggen <erik.verbruggen@me.com>
2019-05-02 09:26:04 +00:00
Friedemann Kleint 34c98070d1 Fix deprecation warnings about QVariant API
Fix warnings like:
sruntime/qv4serialize.cpp:378:45: warning: 'QVariant qVariantFromValue(const T&) [with T = QQmlListModelWorkerAgent::VariantRef]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
qml/qqmlvmemetaobject.cpp:597:61: warning: 'QVariant qVariantFromValue(const T&) [with T = QList<QObject*>]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
jsruntime/qv4engine.cpp:1319:66: warning: 'QVariant qVariantFromValue(const T&) [with T = QObject*]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
jsruntime/qv4engine.cpp:1350:60: warning: 'QVariant qVariantFromValue(const T&) [with T = QList<QObject*>]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
items/qquickitem.cpp:8396:78: warning: 'QVariant qVariantFromValue(const T&) [with T = QObject*]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
items/qquickitem.cpp:8693:80: warning: 'QVariant qVariantFromValue(const T&) [with T = QObject*]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
items/qquickgenericshadereffect.cpp:126:69: warning: 'QVariant qVariantFromValue(const T&) [with T = QObject*]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
items/qquickgenericshadereffect.cpp:127:55: warning: 'QVariant qVariantFromValue(const T&) [with T = QSize]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
items/qquickopenglshadereffect.cpp:713:69: warning: 'QVariant qVariantFromValue(const T&) [with T = QObject*]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
items/qquickopenglshadereffect.cpp:714:55: warning: 'QVariant qVariantFromValue(const T&) [with T = QSize]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
qquickcustomparticle.cpp:416:89: warning: 'QVariant qVariantFromValue(const T&) [with T = double]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
qqmlenginedebugclient.cpp:403:47: warning: 'QVariant qVariantFromValue(const T&) [with T = QQmlEngineDebugObjectReference]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]

Task-number: QTBUG-74043
Change-Id: I14cb7d7c1fb8dc6321e32208a7de15f6bdb19065
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-04-08 08:44:15 +00:00
Simon Hausmann 9f5bd5ab10 Fix storing QObject pointers in dynamic role models
Storing QObject pointers in a dynamic role model man end up crashing the
application once those objects get deleted.

As it looks impossible to make QVariant::fromValue<QObject*>(...) track
the life cycle in a binary compatible way, this patch fixes the crashes
by tracking with a QPointer at the level of QVariant storage. That's the
QQmlOpenMetaObject in the case of the dynamic role model. In principle a
similar approach is already in place for storage of QML declared
properties - this patch mirrors the approach.

Test cases provided by Ben Lau <xbenlau@gmail.com> and Chris Adams
<chris.adams@jollamobile.com>.

Task-number: QTBUG-35639
Change-Id: I0aee227cd2057654c2cb843c4ebb57ed2ec9a8bf
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-05-11 08:51:43 +00:00
Daniel Vrátil cc62a35bbe Fix QQmlListModel crash when appending an empty array in debug mode
Calling QQmlListModel::append() with an empty JS array triggers an assert
in QAbstractItemModel::beginInsertRows() because it's called with
negative "last" parameter.

Change-Id: I202da260d79f2e6677c663c5785ff754c715fef8
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-03-20 22:36:00 +00:00
Shawn Rutledge 499ec43937 use nullptr consistently (clang-tidy)
From now on we prefer nullptr instead of 0 to clarify cases where
we are assigning or testing a pointer rather than a numeric zero.

Also, replaced cases where 0 was passed as Qt::KeyboardModifiers
with Qt::NoModifier (clang-tidy replaced them with nullptr, which
waas wrong, so it was just as well to make the tests more readable
rather than to revert those lines).

Change-Id: I4735d35e4d9f42db5216862ce091429eadc6e65d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-02-26 07:13:18 +00:00
Simon Hausmann 44a89492b4 Fix ListModel.get(idx) == ListModel.get(idx)
This is a regression introduced with commit
4876ea6a18. Where we previously always
returned the same JS object, we would afterwards return a new JS object
for every invocation, which breaks reference comparison. As we store the
JS wrapper for the list element in the QQmlData->jsWrapper we can avoid
repeated allocations. In order for that wrapper to keep working after
modifications (insertion, etc.) to the list model, we have to replace
the static element index with a reference to the node model meta-object,
which also has an element index that however is kept up-to-date by the
list model itself.

Change-Id: I4368de6b6d86687fe96fbf73bd60b80b69d7b058
Task-number: QTBUG-52017
Reviewed-by: Michael Brasser <michael.brasser@live.com>
2018-02-22 13:59:05 +00:00
Simon Hausmann 22d43f74e2 Fix memory leak with ListModel.get
This is a regression introduced with commit
3cc589c983, which in turn fixed a leak
with QV4::QObjectWrapper objects. Unfortunately the allocate() call into
the persistent (weak) value storage in the list model introduced a leak
of the weak value itself. This is fixed by replacing the free standing
weak value allocation with the use of the existing jsWrapper weak value
in the declarative data (QQmlData). That weak value is freed property in
the destroy() method of the QV4::QObjectWRapper. The extra QQmlData
allocation is hidden behind a unified allocation, similar to what we do
in void QQmlType::create(QObject **, void **, size_t) const.

Task-number: QTBUG-66189
Change-Id: I5351e3e484542709a6b210e84aa19b14d28e11ad
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-02-12 19:34:25 +00:00
Lars Knoll 55a671ea73 Merge remote-tracking branch 'origin/5.9' into 5.10
Conflicts:
	src/qml/compiler/qv4compileddata.cpp
	src/qml/compiler/qv4compileddata_p.h
	src/qml/jsruntime/qv4engine.cpp
	src/qml/jsruntime/qv4qmlcontext.cpp
	src/qml/jsruntime/qv4qmlcontext_p.h
	src/qml/jsruntime/qv4regexpobject.cpp
	src/qml/jsruntime/qv4regexpobject_p.h
	src/qml/types/qqmllistmodel.cpp
	src/quick/items/qquickanimatedimage_p.h
	src/quick/scenegraph/qsgrenderloop.cpp
	tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp

Change-Id: If20ef62b2c98bdf656cb2f5d27b1897b754d3dc0
2017-09-20 14:27:41 +02:00
Andy Shaw bfab1db381 Fall back to the ObjectWrapper for model advanceIterator
When falling back to the QObjectWrapper it will add in the extra parts
added when the roles were added to the object created by the model to
hold the data being returned. This was causing the last entry to be
duplicated and causing extra work too.

Task-number: QTBUG-54285
Task-number: QTBUG-62156
Change-Id: I2907477277df8d16db4491a4999f004433e4205c
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-09-15 13:18:53 +00:00
Jarek Kobus dc3015e891 Fix strings
Change-Id: Ib073a4161f68bdde50c9287f66f111a49adb7e26
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2017-05-17 08:46:21 +00:00
Liang Qi cc1c3d0e2b Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
	src/qml/compiler/qv4ssa.cpp
	src/qml/qml/v8/qqmlbuiltinfunctions.cpp
	src/quick/util/qquickprofiler_p.h

Change-Id: I11a89c2a166115d6697adfba09928805643e709e
2016-11-25 23:35:34 +01:00
Simon Hausmann 1969991c4a Fix binding re-evaluation when list model properties change
This is a regression from commit
4876ea6a18, which avoided returning an
expensive QObject when calling get() but also lost the ability to
perform binding captures when accessing the properties. This change
restores the captures by performing them by hand in get() and also
triggering the notifiers directly when the values change, without
creating the QObject.

Task-number: QTBUG-52356
Change-Id: Ia429ffafd4032b63d3e592aa63bb0864a24e0965
Reviewed-by: Michael Brasser <michael.brasser@live.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2016-11-18 11:06:31 +00:00
Liang Qi 0932a59971 Merge remote-tracking branch 'origin/5.6' into 5.7
Part of 0e053528 was reverted in the merge, about lastTimestamp. It
will be applied later in separate commit.

qmltest::shadersource-dynamic-sourceobject::test_endresult() was
blacklisted on linux.

Conflicts:
	.qmake.conf
	tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
	tests/auto/qmltest/BLACKLIST
	tests/auto/qmltest/qmltest.pro

Task-number: QTBUG-53590
Task-number: QTBUG-53971
Change-Id: I48af90b49a3c7b29de16f4178a04807f8bc05130
2016-06-10 10:06:39 +02:00
Filipe Azevedo 82b0b31fe4 Fix crash for unknown QQmlListModel roles in debug builds
If a role is unknown, trying to access it will crash in getExistingRole.
Fixed that and now return QVariant() for unknown roles.

Change-Id: Iad5c1292a4faee893fbc5a69984cf776aca85d70
Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com>
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2016-05-23 14:01:42 +00:00
Jani Heikkinen 38ec3bd755 Updated license headers
From Qt 5.7 -> tools & applications are lisenced under GPL v3 with some
exceptions, see
http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/

Updated license headers to use new GPL-EXCEPT header instead of LGPL21 one
(in those files which will be under GPL 3 with exceptions)

Change-Id: I04760a0801837cfc516d1c7c02d4f503f6bb70b6
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
2016-01-20 11:46:25 +00:00
Friedemann Kleint 0f5a721761 Tests: Fix single-character string literals.
Use character literals where applicable.

Change-Id: Ib0e618752fbc762a73a0a91c43efab61ef2c9687
Reviewed-by: Ulf Hermann <ulf.hermann@theqtcompany.com>
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-10-13 14:24:16 +00:00
Tobias Koenig 4253f11774 Implement QQmlListModel::setData()
Extending QQmlListModel by setData allows us
to modify the content of the ListModel from
within a delegate by doing an 'model.someProp = someValue'
assignment.

Change-Id: I87e4c31aca3813f099b2a4fd694beb2492a03bd0
Reviewed-by: Alan Alpert <aalpert@blackberry.com>
2015-09-14 15:56:16 +00:00
Friedemann Kleint 0ea3c24cfe tests/qml: Replace Q[TRY]_VERIFY(a == b) by Q[TRY]_COMPARE(a, b).
- Replace Q[TRY]_VERIFY(pointer == 0) by Q[TRY]_VERIFY(!pointer).
- Replace Q[TRY]_VERIFY(smartPointer == 0)  by
          Q[TRY]_VERIFY(smartPointer.isNull()).
- Replace Q[TRY]_VERIFY(a == b) by  Q[TRY]_COMPARE(a, b) and
  add casts where necessary. The values will then be logged
  should a test fail.

Change-Id: I8cc97fd9b48fc789a849e9527c292c4e05accd97
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
2015-07-29 09:44:39 +00:00
Jani Heikkinen c5796292ad Update copyright headers
Qt copyrights are now in The Qt Company, so we could update the source
code headers accordingly. In the same go we should also fix the links to
point to qt.io.

Change-Id: I61120571787870c0ed17066afb31779b1e6e30e9
Reviewed-by: Iikka Eklund <iikka.eklund@theqtcompany.com>
2015-02-12 10:28:11 +00:00
Jani Heikkinen e7ceacda70 Update license headers and add new licenses
- Renamed LICENSE.LGPL to LICENSE.LGPLv21
- Added LICENSE.LGPLv3 & LICENSE.GPLv2
- Removed LICENSE.GPL

Change-Id: I84a565e2e0caa3b76bf291a7d188a57a4b00e1b0
Reviewed-by: Jani Heikkinen <jani.heikkinen@digia.com>
2014-08-25 11:28:46 +02:00
Simon Hausmann 11a11d1280 Merge remote-tracking branch 'origin/stable' into dev
The merge conflict is about the removal of "d1" from the register
set on ARM, but that was already done in dev in commit ddb33ee9ba

The change in src/quick/scenegraph/coreapi/qsgrenderer.cpp with commit 2414f1675e
was reverted to what it was before, per Laszlo's advice.

Conflicts:
	src/qml/jit/qv4isel_masm.cpp

Change-Id: I7bce546c5cdee01e37853a476d82279d4e72948b
2014-06-04 17:02:55 +02:00
Simon Hausmann 52e07d564b Rework custom parser integration
The custom parser design used to be so that the custom parser operates on the "AST",
creates its own binary representation of the data it needs, stores it in a QByteArray
and gets that at object instantiation time. That meant serializing everything necessary.
With the introduction of the "binary" QML data structure, that process of serialization
becomes obsolete and would require extra work in the custom parsers for example for QQuickStates
to store the translation parameters.

The clean solution is to eliminate this unnecessary serialization process and
instead let the custom parsers do a verification pass at type compile time and
then simply operate directly on the QV4::CompiledData::Bindings at object
instantiation time. That simplifies the code, and allows for support of
translations throughout all list model properties.

Additionally this speeds up the creation of state objects and reduces memory
consumption. Previously a text: qsTr("foo") binding in states would result in
an actual java script binding. After this patch it is merely stored as a string
and translated at object instantiation time.

Change-Id: I7550274513f54abb09a0ab4de51c4c0bcdb23cae
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2014-06-04 08:25:52 +02:00
J-P Nurmi 0306626a4d Fix emission of QQmlListModel::rowsAboutToBeXxx() signals
Call beginInsertRows(), beginMoveRows() and beginRemoveRows() before
the change to ensure that rowsAboutToBeInserted(), rowsAboutToBeMoved()
and rowsAboutToBeRemoved() get emitted before the change as appropriate.

NOTE: This patch solves the problem for the most common use case, when
ListModel is used without WorkerScript. QQmlListModelWorkerAgent needs
similar changes in order to fix the signals when ListModel is used with
WorkerScript (QTBUG-39321).

Task-number: QTBUG-39279
Change-Id: Idec5167d70b242f6f7d8b7cff008e130afc62505
Reviewed-by: Alan Alpert <aalpert@blackberry.com>
2014-05-29 09:25:44 +02:00
Simon Hausmann 68a662a2e1 Fix translations in states causing failing assertions
This is a smaller fix suitable for the release branch, merely adding support
for translations to the bytearray compilation step for states and ensuring a
consistent error message when qsTr is used in list models.

The proper fix will be done in dev that eliminates the entire intermediate
QByteArray storage for custom compilers.

Task-number: QTBUG-38492
Change-Id: If5171f16eb742c718e48b8bbcb265b0c241cd5e7
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2014-04-28 12:50:17 +02:00
Simon Hausmann 61e519e230 Eliminate noop translation bindings
We can store them as regular strings. This has the advantage that the
entire special handling from the custom parser of the list model goes away,
we don't need astForBinding in QQmlCustomParser anymore neither and types
with a custom parser can now generally benefit from the expression simplification
pass.

Change-Id: I39d1b76edd1273d8c73b847aed71f7bcce37d877
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2014-03-29 21:20:32 +01:00
Simon Hausmann 212e961fc8 Fix crash when appending arrays to sub models in list models
The elements are still inaccessible, but at least it doesn't crash. This is
consistent with the behavior in Qt 5.0, where it didn't crash because the v8
object handle returned an empty array for the property names because the
individual array element wasn't an object.

Bug QTBUG-12117 tracks support for arrays in list models.

Task-number: QTBUG-35891
Change-Id: Ief446341344977a1473bca474ca5ba934e950468
Reviewed-by: Albert Astals Cid <albert.astals@canonical.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2014-03-14 12:38:36 +01:00
J-P Nurmi 691469c05c Fix ListModel::setProperty() to accept date roles
Task-number: QTBUG-33564
Change-Id: Ifbc1c5014d41b26223c57fafdc616e9b4ddee5b8
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
2014-02-20 12:45:41 +01:00
Lars Knoll 34b69c3ce4 Fix expected test output for one list model test
There's no reason to disallow calling model.set() with
an ArrayObject as argument.

Change-Id: I44baad677ca34e1fb4188b89f0a548af84580b4f
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-06-21 14:14:02 +02:00
Bernd Weimer c460a83e26 Fixed some auto tests
In the listmodel test an error description was not converted to a
string.
In the pathview test, number literals are always interpreted as double,
but qreal can also be float, which lead to failing tests. Constructor
usage prevents "expected data of type 'float', got 'double'".

Change-Id: I0c760486de0ba4df6a5e9a33e9528ca7d7a1a63e
Reviewed-by: Alan Alpert <aalpert@blackberry.com>
2013-03-12 18:22:02 +01:00
Alan Alpert bbb3d5b403 Move ListModel and ListElement to the QtQml import
They're already in the QtQml module, but were left in the QtQuick import
because they were considered to be of minimal use without QtQuick types.

QtQml types are being developed would could make ListModel useful
without QtQuick, indicating that they should no longer be considered
QtQuick depedent.

Change-Id: I31499f2cc23baf4bc70fb451ba164408bed89ff6
Reviewed-by: Andrew den Exter <andrew.den.exter@qinetic.com.au>
2013-01-24 17:14:12 +01:00