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 <volker.hilsheimer@qt.io>
This commit is contained in:
Tor Arne Vestbø 2022-11-10 15:39:46 +01:00
parent c1088d493e
commit b2de858a8c

View File

@ -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);
}