Utils: Fix AspectContainer::setAutoApply

Removes duplicate m_autoApply from AspectContainerPrivate.
Fixes issue when calling BaseAspect::setAutoApply()
on an AspectContainer.

Change-Id: I5f56d8d3c6d52d32c9365faf3d0e22facb757f03
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Marcus Tillmanns
2023-09-12 08:57:05 +02:00
parent 2494ba4bf8
commit 8bcec807d9
2 changed files with 5 additions and 5 deletions

View File

@@ -2479,7 +2479,6 @@ class Internal::AspectContainerPrivate
public:
QList<BaseAspect *> m_items; // Both owned and non-owned.
QList<BaseAspect *> m_ownedItems; // Owned only.
bool m_autoApply = true;
QStringList m_settingsGroup;
std::function<Layouting::LayoutItem ()> m_layouter;
};
@@ -2501,7 +2500,7 @@ AspectContainer::~AspectContainer()
*/
void AspectContainer::registerAspect(BaseAspect *aspect, bool takeOwnership)
{
aspect->setAutoApply(d->m_autoApply);
aspect->setAutoApply(isAutoApply());
d->m_items.append(aspect);
if (takeOwnership)
d->m_ownedItems.append(aspect);
@@ -2631,7 +2630,8 @@ void AspectContainer::reset()
void AspectContainer::setAutoApply(bool on)
{
d->m_autoApply = on;
BaseAspect::setAutoApply(on);
for (BaseAspect *aspect : std::as_const(d->m_items))
aspect->setAutoApply(on);
}

View File

@@ -79,7 +79,7 @@ public:
void setVisible(bool visible);
bool isAutoApply() const;
void setAutoApply(bool on);
virtual void setAutoApply(bool on);
bool isEnabled() const;
void setEnabled(bool enabled);
@@ -860,7 +860,7 @@ public:
void reset();
bool equals(const AspectContainer &other) const;
void copyFrom(const AspectContainer &other);
void setAutoApply(bool on);
void setAutoApply(bool on) override;
bool isDirty() override;
template <typename T> T *aspect() const