aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates/qquickcontainer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/quicktemplates/qquickcontainer.cpp')
-rw-r--r--src/quicktemplates/qquickcontainer.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/quicktemplates/qquickcontainer.cpp b/src/quicktemplates/qquickcontainer.cpp
index eefc9161e9..115168083c 100644
--- a/src/quicktemplates/qquickcontainer.cpp
+++ b/src/quicktemplates/qquickcontainer.cpp
@@ -116,7 +116,7 @@ QT_BEGIN_NAMESPACE
Container does not provide any default visualization. It is used to implement
such containers as \l SwipeView and \l TabBar. When implementing a custom
container, the most important part of the API is \l contentModel, which provides
- the contained items in a way that it can be used as a delegate model for item
+ the contained items in a way that it can be used as an object model for item
views and repeaters.
\code
@@ -167,6 +167,7 @@ void QQuickContainerPrivate::init()
QObject::connect(contentModel, &QQmlObjectModel::childrenChanged, q, &QQuickContainer::contentChildrenChanged);
connect(q, &QQuickControl::implicitContentWidthChanged, this, &QQuickContainerPrivate::updateContentWidth);
connect(q, &QQuickControl::implicitContentHeightChanged, this, &QQuickContainerPrivate::updateContentHeight);
+ setSizePolicy(QLayoutPolicy::Preferred, QLayoutPolicy::Preferred);
}
void QQuickContainerPrivate::cleanup()
@@ -256,7 +257,8 @@ void QQuickContainerPrivate::moveItem(int from, int to, QQuickItem *item)
void QQuickContainerPrivate::removeItem(int index, QQuickItem *item)
{
Q_Q(QQuickContainer);
- if (!q->isContent(item))
+ const bool item_inDestructor = QQuickItemPrivate::get(item)->inDestructor;
+ if (!item_inDestructor && !q->isContent(item))
return;
contentData.removeOne(item);
@@ -271,8 +273,11 @@ void QQuickContainerPrivate::removeItem(int index, QQuickItem *item)
currentChanged = true;
}
- QQuickItemPrivate::get(item)->removeItemChangeListener(this, changeTypes);
- item->setParentItem(nullptr);
+ if (!item_inDestructor) {
+ // already handled by ~QQuickItem
+ QQuickItemPrivate::get(item)->removeItemChangeListener(this, changeTypes);
+ item->setParentItem(nullptr);
+ }
contentModel->remove(index);
--count;