forked from qt-creator/qt-creator
Utils: Shortcut Aspect::isDirty for aspects that were never visible
Also do not access Aspect::volatileValue if aspect was never shown In this case, user-induced unsaved changes cannot exist. This also avoids QTC_ASSERT in the volatileValue() implementations in these cases. Silences the contained QTC_ASSERTs properly and avoids returning a null-variant that's likely not identical to the default value. Change-Id: Idba89997d0b0b4f9b7dcac0881afe36b35ccdf7c Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -406,6 +406,7 @@ void BaseAspect::addToLayout(LayoutBuilder &)
|
|||||||
void BaseAspect::apply()
|
void BaseAspect::apply()
|
||||||
{
|
{
|
||||||
QTC_CHECK(!d->m_autoApply);
|
QTC_CHECK(!d->m_autoApply);
|
||||||
|
if (isDirty())
|
||||||
setValue(volatileValue());
|
setValue(volatileValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -418,6 +419,7 @@ void BaseAspect::apply()
|
|||||||
void BaseAspect::cancel()
|
void BaseAspect::cancel()
|
||||||
{
|
{
|
||||||
QTC_CHECK(!d->m_autoApply);
|
QTC_CHECK(!d->m_autoApply);
|
||||||
|
if (!d->m_subWidgets.isEmpty())
|
||||||
setVolatileValue(d->m_value);
|
setVolatileValue(d->m_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -434,6 +436,9 @@ bool BaseAspect::hasAction() const
|
|||||||
bool BaseAspect::isDirty() const
|
bool BaseAspect::isDirty() const
|
||||||
{
|
{
|
||||||
QTC_CHECK(!isAutoApply());
|
QTC_CHECK(!isAutoApply());
|
||||||
|
// Aspects that were never shown cannot contain unsaved user changes.
|
||||||
|
if (d->m_subWidgets.isEmpty())
|
||||||
|
return false;
|
||||||
return volatileValue() != d->m_value;
|
return volatileValue() != d->m_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user