aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlmodels/qqmlobjectmodel.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Add security header for src/qmlmodelsFabian Kosmale2025-09-161-0/+1
| | | | | | | | | | | | As we assume that all QML comes from trusted sources, everything remains at the default "signicant" security level. The exception are the module headers which only include other headers and add a few defines. QUIP: 23 Fixes: QTBUG-136203 Pick-to: 6.10 6.9 6.8 Change-Id: Ib1a2abbb94dbb25420f03e01a2b444f89517a902 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QmlModels: Clean up some virtual functions and dtorsUlf Hermann2025-03-011-0/+2
| | | | | | | | Virtual functions shouldn't be inline, and non-virtual empty dtors are unnecessary. Change-Id: I86b6c6b1d0135f4076c0c3f8287f314c3f007b78 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* QQmlObjectModel: Mark elements when marking the object modelUlf Hermann2024-09-251-19/+78
| | | | | | | | | | | | | | This prevents the GC from deleting the objects while the object model still holds on to them. [ChangeLog][QtQmlModels][Important Behavior Changes] ObjectModel will not let the garbage collector destroy any JavaScript-owned objects it holds anymore. It now properly references them. C++-owned objects still behave the same. Fixes: QTBUG-124345 Change-Id: I979f41e6f27a7fc36c2c161be2bbd5db1bad3eaf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlObjectModel: Guard against spontaneous deletion of objectsUlf Hermann2024-08-221-6/+8
| | | | | | | | | | | | Since QQmlObjectModel does not own its elements, we cannot assume anything about their life cycle. Observe the elements using QPointer and do not access them anymore when they are dead. Pick-to: 6.8 Task-number: QTBUG-124345 Change-Id: I3ba806ae2bbc6ec0b0d97ae6c51cea32e25d4508 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Doc: Replace \instantiates with \nativetypePaul Wicking2024-08-201-1/+1
| | | | | | | | | | | Since the implementation of the `\nativetype`-command in QDoc, the `\instantiates`-command is deprecated. Replace the use of the deprecated command in favor of its replacement. Pick-to: 6.8 Task-number: QTBUG-128216 Change-Id: I23d9f66d3f6db2e5f827d7868497a432bb9b0626 Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
* QQmlObjectModel: Do not store attached objects in global staticUlf Hermann2024-08-121-22/+24
| | | | | | | | | | | | | This is rather dangerous. The global static is not protected in any way against concurrent access. However, we already have a place to store attached objects. The base object's QQmlData. Just use that. Pick-to: 6.8 Task-number: QTBUG-124345 Change-Id: I5f254e640f836016564f297d2f39ea40e037acd8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* Port to new Q_UNREACHABLE_RETURN()Marc Mutz2022-10-201-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator to convert sequences of Q_UNREACHABLE() + return into Q_UNREACHABLE_RETURN(), newly added to qtbase. const std::string unr = "unr", val = "val", ret = "ret"; auto makeUnreachableReturn = cat("Q_UNREACHABLE_RETURN(", ifBound(val, cat(node(val)), cat("")), ")"); auto ignoringSwitchCases = [](auto stmt) { return anyOf(stmt, switchCase(subStmt(stmt))); }; makeRule(stmt(ignoringSwitchCases(stmt(isExpandedFromMacro("Q_UNREACHABLE")).bind(unr)), nextStmt(returnStmt(optionally(hasReturnValue(expr().bind(val)))).bind(ret))), {changeTo(node(unr), cat(makeUnreachableReturn, ";")), // TODO: why is the ; lost w/o this? changeTo(node(ret), cat(""))}, cat("use ", makeUnreachableReturn)); a.k.a qt-use-unreachable-return. subStmt() and nextStmt() are non-standard matchers. There was one false positive, suppressed it with NOLINTNEXTLINE. It's not really a false positiive, it's just that Clang sees the world in one way and if conditonal compilation (#if) differs for other compilers, Clang doesn't know better. This is an artifact of matching two consecutive statements. Change-Id: I3855b2dc8523db1ea860f72ad9818738162495c6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Port from container::count() and length() to size()Marc Mutz2022-10-071-10/+10
| | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8: auto QtContainerClass = anyOf( expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o), expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)); makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container', with the extended set of container classes recognized. Change-Id: Idb1f75dfe2323bd1d9e8b4d58d54f1b4b80c7ed7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-111-38/+2
| | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* qqmltableinstancemodel: add setRequiredProperty()Richard Moe Gustavsen2021-04-301-0/+11
| | | | | | | | | | | | | | | | Add a virtual function setRequiredProperty() to QQmlInstanceModel that we override in QQmlTableInstanceModel. This function can be called from QQuickTableView, upon getting the initItem signal, to assign initial values to any required properties that the view makes use of. This patch is added as a preparation for adding selection support to QQuickTableView (which will make use of "required property isSelected" on the delegate) Change-Id: I55885bafa14da1d432c120bef807e73165f1466c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlListProperty: Use qsizetype rather than int for sizesUlf Hermann2020-11-091-4/+4
| | | | | | | | | | [ChangeLog][QtQml] The QQmlListProperty callback functions use qsizetype now as type for the size of a list. This is in line with the containers that you might use to back the list. Fixes: QTBUG-88269 Change-Id: Ia38403cb32f241e6c70e1a580dbeff1d6d694331 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Doc: Fix documentation warnings for QML Models and Test modulesTopi Reinio2020-11-051-2/+2
| | | | | | Fixes: QTBUG-88156 Change-Id: Ie9723f1bb612f4603d15455a0320cc01b27ff181 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-02-171-6/+28
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/imports/qtqml/plugin.cpp src/qml/qml/qqml.h src/qml/qml/qqmlmetatype.cpp src/qml/qml/qqmlmetatype_p.h src/qml/qml/qqmltypeloader.cpp src/qml/types/qqmlbind.cpp src/quick/items/qquickitemsmodule.cpp tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp Change-Id: I52548938a582cb6510271ed4bc3a9aa0c3c11df6
| * Fix QQmlObjectModel::destroyingItem emissionSimon Hausmann2020-02-101-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The signal is used to tell the view that the item is definitely going away. For the "view" based QQmlObjectModel that is almost never really the case, except - oddly - for clear(). The view is typically a QQuickItemView, which casts the item to a QQuickItem and calls setParentItem(nullptr). That in turn is caught by QQuickContainer, which calls remove() on the QQmlObjectModel. That is why remove() can't emit destroyingItem(). Amends 6d0a453f41d304239285d64b06612c36922be701 Change-Id: I5d82def872550744b947b4b53447647327e03f67 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
| * Use the extended QQmlListProperty interface in a few placesUlf Hermann2020-02-071-9/+30
| | | | | | | | | | | | | | Task-number: QTBUG-79263 Change-Id: If518f644b5b9eddbacfb1cb16fbb557127ffcfb2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2019-12-121-2/+2
|\| | | | | | | | | | | | | Conflicts: src/qml/types/qqmlbind.cpp Change-Id: Ib992d1a7ac6c1a96d39819be6f23955dc31b44b2
| * QQmlTableInstanceModel: factor out reuse poolRichard Moe Gustavsen2019-12-041-1/+1
| | | | | | | | | | | | | | | | | | Factor out the reuse pool logic in TableInstanceModel into a separate class, so that we can share it with the upcoming implementation for recycling items in QQmlDelegateModel. Change-Id: If8f700b7a0208bac7d1cb1de087792e2c3a9b512 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
| * Avoid initializing QFlags with 0 or nullptr in further casesFriedemann Kleint2019-11-251-1/+1
| | | | | | | | | | | | | | Amends 744e77b841878fb017c0f2d60607090008f28180. Change-Id: I16e37aaf503eb62f67fca0e48be4c92c4a72ae46 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | Take a copy of the children list before emitting the destroyingItem signalLars Knoll2019-11-011-1/+4
|/ | | | | | | | | | | | clear() emits a signal for each item that is being destroyed. Unfortunately that signal can be connected to some other place that already removes the item indirectly. In that case, we would not correctly emit the destroyed signal for all items, leading to errors later on. Fixes a test failure in Qt Quick Controls 2 Change-Id: I3aff75d9263badd9f87883610c7a00a94ee823d3 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* QQmlObjectModel: Return object property from variantValue()Ulf Hermann2019-10-211-1/+1
| | | | | | | | | | | | | | Returning a context property was a strange choice. We want to get rid of context properties. [ChangeLog][Important Behavior Changes] The QML ObjectModel type had an undocumented "feature" which made it sort items in list views into sections according to context properties of the QML context the created objects belong to. Instead of context properties, object properties are used now. Change-Id: Ibd94c903910f0cdb76ead50db92a24eefebfa3fc Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.13' into 5.14Liang Qi2019-09-121-4/+4
| | | | | | | | | | | | Conflicts: src/qml/jsruntime/qv4engine.cpp src/quick/handlers/qquicktaphandler.cpp src/quick/items/qquicktableview.cpp Done-With: Richard Moe Gustavsen <richard.gustavsen@qt.io> Done-With: Ulf Hermann <ulf.hermann@qt.io> Done-With: Shawn Rutledge <shawn.rutledge@qt.io> Change-Id: If9558a33f01693ce96420c094e0b57dfff0626cd
* Move model types into their own libraryUlf Hermann2019-05-021-0/+431
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>