From 6a78272ac81be7145f4862046afdd6c3f342234b Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 18 Mar 2024 11:48:25 +0100 Subject: [PATCH] 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 eda5fbd64575c0c268ba173e778a256a84484191 Change-Id: I69b86a967ee1fe7bd3d5d035765349981b64eb72 Reviewed-by: Qt CI Bot Reviewed-by: Christian Stenger --- src/plugins/qtsupport/qtbuildaspects.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/qtsupport/qtbuildaspects.cpp b/src/plugins/qtsupport/qtbuildaspects.cpp index e941dcb1872..2f6ee192206 100644 --- a/src/plugins/qtsupport/qtbuildaspects.cpp +++ b/src/plugins/qtsupport/qtbuildaspects.cpp @@ -35,7 +35,6 @@ void QmlDebuggingAspect::addToLayout(Layouting::LayoutItem &parent) SelectionAspect::addToLayout(parent); const auto warningLabel = createSubWidget(QString(), InfoLabel::Warning); warningLabel->setElideMode(Qt::ElideNone); - warningLabel->setVisible(false); parent.addRow({{}, warningLabel}); const auto changeHandler = [this, warningLabel] { QString warningText; @@ -51,7 +50,9 @@ void QmlDebuggingAspect::addToLayout(Layouting::LayoutItem &parent) warningLabel->setText(warningText); setVisible(supported); 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); }; connect(KitManager::instance(), &KitManager::kitsChanged, warningLabel, changeHandler);