@@ -32,6 +32,7 @@ void PendingRegion::setItem(QQuickItem* item) {
3232
3333 if (this ->mItem != nullptr ) {
3434 QObject::disconnect (this ->mItem , nullptr , this , nullptr );
35+ this ->disconnectParentChain ();
3536 }
3637
3738 this ->mItem = item;
@@ -42,15 +43,41 @@ void PendingRegion::setItem(QQuickItem* item) {
4243 QObject::connect (this ->mItem , &QQuickItem::yChanged, this , &PendingRegion::itemChanged);
4344 QObject::connect (this ->mItem , &QQuickItem::widthChanged, this , &PendingRegion::itemChanged);
4445 QObject::connect (this ->mItem , &QQuickItem::heightChanged, this , &PendingRegion::itemChanged);
46+ this ->connectParentChain (item);
4547 }
4648
4749 emit this ->itemChanged ();
4850}
4951
50- void PendingRegion::onItemDestroyed () { this ->mItem = nullptr ; }
52+ void PendingRegion::onItemDestroyed () {
53+ this ->mItem = nullptr ;
54+ this ->disconnectParentChain ();
55+ }
5156
5257void PendingRegion::onChildDestroyed () { this ->mRegions .removeAll (this ->sender ()); }
5358
59+ void PendingRegion::connectParentChain (QQuickItem* item) {
60+ this ->disconnectParentChain ();
61+
62+ auto * parent = item->parentItem ();
63+ while (parent != nullptr ) {
64+ this ->mParentConnections .push_back (
65+ QObject::connect (parent, &QQuickItem::xChanged, this , &PendingRegion::itemChanged)
66+ );
67+ this ->mParentConnections .push_back (
68+ QObject::connect (parent, &QQuickItem::yChanged, this , &PendingRegion::itemChanged)
69+ );
70+ parent = parent->parentItem ();
71+ }
72+ }
73+
74+ void PendingRegion::disconnectParentChain () {
75+ for (const auto & connection: this ->mParentConnections ) {
76+ QObject::disconnect (connection);
77+ }
78+ this ->mParentConnections .clear ();
79+ }
80+
5481qint32 PendingRegion::radius () const { return this ->mRadius ; }
5582
5683void PendingRegion::setRadius (qint32 radius) {
0 commit comments