From b2de858a8c55b7859d6d85ff3f0dcb8ecc7e1413 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 10 Nov 2022 15:39:46 +0100 Subject: [PATCH] QColorDialog: Account for native dialog helper not being able to show The color dialog implementation lazily initializes the widget hierarchy, so that they are not created if we're using a native dialog. But unlike QFileDialog, which does the same, QColorDialog failed to handle the case where the native helper could not show a native dialog. We now correctly lazy initialize the widget hierarchy if the native show fails. The WA_DontShowOnScreen state management has been left out, as it needs some general refactoring. This patch doesn't fix, or regress, any logic related to WA_DontShowOnScreen. Task-number: QTBUG-108153 Change-Id: Icbd506617a2fe302bb61aab977e7c8ea4bd64878 Reviewed-by: Volker Hilsheimer --- src/widgets/dialogs/qcolordialog.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index e9c7c0a514..d19635bd77 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.cpp @@ -2117,10 +2117,13 @@ void QColorDialog::setVisible(bool visible) d->selectedQColor = QColor(); if (d->nativeDialogInUse) { - d->setNativeDialogVisible(visible); - // Set WA_DontShowOnScreen so that QDialog::setVisible(visible) below - // updates the state correctly, but skips showing the non-native version: - setAttribute(Qt::WA_DontShowOnScreen); + if (d->setNativeDialogVisible(visible)) { + // Set WA_DontShowOnScreen so that QDialog::setVisible(visible) below + // updates the state correctly, but skips showing the non-native version: + setAttribute(Qt::WA_DontShowOnScreen); + } else { + d->initWidgets(); + } } else { setAttribute(Qt::WA_DontShowOnScreen, false); }