forked from qt-creator/qt-creator
Fix visibility of vulnerability warning for QML debugging
The warning was not shown when opening a project with the QML debugging
option enabled.
The `changeHandler` was explicitly called at construction, but at this
point the `warningLabel` doesn't have a parent. The `setVisible` call
was skipped in this case, to prevent opening a toplevel window (for a
short time) for it until it has a parent.
Unfortunately there is no Qt API for setting the "visibility to the
parent". Instead invert the logic: Let the label have default visibility
to start with (which is "visible if the parent is visible"), and force
it to hidden in `changeHandler` if necessary.
Amends eda5fbd645
Change-Id: I69b86a967ee1fe7bd3d5d035765349981b64eb72
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -35,7 +35,6 @@ void QmlDebuggingAspect::addToLayout(Layouting::LayoutItem &parent)
|
|||||||
SelectionAspect::addToLayout(parent);
|
SelectionAspect::addToLayout(parent);
|
||||||
const auto warningLabel = createSubWidget<InfoLabel>(QString(), InfoLabel::Warning);
|
const auto warningLabel = createSubWidget<InfoLabel>(QString(), InfoLabel::Warning);
|
||||||
warningLabel->setElideMode(Qt::ElideNone);
|
warningLabel->setElideMode(Qt::ElideNone);
|
||||||
warningLabel->setVisible(false);
|
|
||||||
parent.addRow({{}, warningLabel});
|
parent.addRow({{}, warningLabel});
|
||||||
const auto changeHandler = [this, warningLabel] {
|
const auto changeHandler = [this, warningLabel] {
|
||||||
QString warningText;
|
QString warningText;
|
||||||
@@ -51,7 +50,9 @@ void QmlDebuggingAspect::addToLayout(Layouting::LayoutItem &parent)
|
|||||||
warningLabel->setText(warningText);
|
warningLabel->setText(warningText);
|
||||||
setVisible(supported);
|
setVisible(supported);
|
||||||
const bool warningLabelsVisible = supported && !warningText.isEmpty();
|
const bool warningLabelsVisible = supported && !warningText.isEmpty();
|
||||||
if (warningLabel->parentWidget())
|
// avoid explicitly showing the widget when it doesn't have a parent, but always
|
||||||
|
// explicitly hide it when necessary
|
||||||
|
if (warningLabel->parentWidget() || !warningLabelsVisible)
|
||||||
warningLabel->setVisible(warningLabelsVisible);
|
warningLabel->setVisible(warningLabelsVisible);
|
||||||
};
|
};
|
||||||
connect(KitManager::instance(), &KitManager::kitsChanged, warningLabel, changeHandler);
|
connect(KitManager::instance(), &KitManager::kitsChanged, warningLabel, changeHandler);
|
||||||
|
Reference in New Issue
Block a user