forked from qt-creator/qt-creator
Utils: Use QPointer for registered aspect subwidgets
Amends 67a3d2e3d1
.
Change-Id: I4807fd3409f66b10de5c95d7b07ddfdc7cf9174f
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -61,7 +61,7 @@ public:
|
|||||||
bool m_enabled = true;
|
bool m_enabled = true;
|
||||||
bool m_readOnly = true;
|
bool m_readOnly = true;
|
||||||
BaseAspect::ConfigWidgetCreator m_configWidgetCreator;
|
BaseAspect::ConfigWidgetCreator m_configWidgetCreator;
|
||||||
QList<QWidget *> m_subWidgets;
|
QList<QPointer<QWidget>> m_subWidgets;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Internal
|
} // Internal
|
||||||
@@ -125,8 +125,10 @@ bool BaseAspect::isVisible() const
|
|||||||
void BaseAspect::setVisible(bool visible)
|
void BaseAspect::setVisible(bool visible)
|
||||||
{
|
{
|
||||||
d->m_visible = visible;
|
d->m_visible = visible;
|
||||||
for (QWidget *w : qAsConst(d->m_subWidgets))
|
for (QWidget *w : qAsConst(d->m_subWidgets)) {
|
||||||
|
QTC_ASSERT(w, continue);
|
||||||
w->setVisible(visible);
|
w->setVisible(visible);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString BaseAspect::toolTip() const
|
QString BaseAspect::toolTip() const
|
||||||
@@ -140,21 +142,26 @@ QString BaseAspect::toolTip() const
|
|||||||
void BaseAspect::setToolTip(const QString &tooltip)
|
void BaseAspect::setToolTip(const QString &tooltip)
|
||||||
{
|
{
|
||||||
d->m_tooltip = tooltip;
|
d->m_tooltip = tooltip;
|
||||||
for (QWidget *w : qAsConst(d->m_subWidgets))
|
for (QWidget *w : qAsConst(d->m_subWidgets)) {
|
||||||
|
QTC_ASSERT(w, continue);
|
||||||
w->setToolTip(tooltip);
|
w->setToolTip(tooltip);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseAspect::setEnabled(bool enabled)
|
void BaseAspect::setEnabled(bool enabled)
|
||||||
{
|
{
|
||||||
d->m_enabled = enabled;
|
d->m_enabled = enabled;
|
||||||
for (QWidget *w : qAsConst(d->m_subWidgets))
|
for (QWidget *w : qAsConst(d->m_subWidgets)) {
|
||||||
|
QTC_ASSERT(w, continue);
|
||||||
w->setEnabled(enabled);
|
w->setEnabled(enabled);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseAspect::setReadOnly(bool readOnly)
|
void BaseAspect::setReadOnly(bool readOnly)
|
||||||
{
|
{
|
||||||
d->m_readOnly = readOnly;
|
d->m_readOnly = readOnly;
|
||||||
for (QWidget *w : qAsConst(d->m_subWidgets)) {
|
for (QWidget *w : qAsConst(d->m_subWidgets)) {
|
||||||
|
QTC_ASSERT(w, continue);
|
||||||
if (auto lineEdit = qobject_cast<QLineEdit *>(w))
|
if (auto lineEdit = qobject_cast<QLineEdit *>(w))
|
||||||
lineEdit->setReadOnly(readOnly);
|
lineEdit->setReadOnly(readOnly);
|
||||||
else if (auto textEdit = qobject_cast<QTextEdit *>(w))
|
else if (auto textEdit = qobject_cast<QTextEdit *>(w))
|
||||||
|
Reference in New Issue
Block a user