aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickcontrol.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2018-03-23 15:17:14 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2018-03-23 17:35:37 +0000
commitc0471d5fd13d817580a2e9cffa27f92775a2d32c (patch)
tree226fca6ea174d67cfbc20f878b325bd8a92778ed /src/quicktemplates2/qquickcontrol.cpp
parenta064824341375206603f794e2b8d8b1f87f016a8 (diff)
Fix QQuickControl::contentItemChange()
All other similar change() virtuals, such as fontChange(), localeChange() and paletteChange(), are called _after_ the value has been applied. The old value is passed as an argument. Use the same order for contentItem. This allows calling such methods from contentItemChange(), that rely on d->contentItem being set. If d->contentItem points to the old content item, all methods need to take the new item as an argument, which gets ugly especially if the same methods are used from elsewhere too. This is very well visible in QQuickPanePrivate: - bool updateContentWidth(QQuickItem *item); - bool updateContentHeight(QQuickItem *item); - void updateContentSize(QQuickItem *item); These are called with "newItem" from contentItemChange(), and with "d->contentItem" from many other places. Note: if a pre-notifications were required for something in the future, it would be probably better to add "aboutToChange" counterparts. Change-Id: I67dfdcce0e5f1cd9d9a37a63a0a9fdeaf82eafe6 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickcontrol.cpp')
-rw-r--r--src/quicktemplates2/qquickcontrol.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp
index fbe46206..fd206eea 100644
--- a/src/quicktemplates2/qquickcontrol.cpp
+++ b/src/quicktemplates2/qquickcontrol.cpp
@@ -336,9 +336,10 @@ void QQuickControlPrivate::setContentItem_helper(QQuickItem *item, bool notify)
if (!contentItem.isExecuting())
cancelContentItem();
- q->contentItemChange(item, contentItem);
- delete contentItem;
+ QQuickItem *oldContentItem = contentItem;
contentItem = item;
+ q->contentItemChange(item, oldContentItem);
+ delete oldContentItem;
if (item) {
if (!item->parentItem())