Dialogs: don't create platform helpers unconditionally
No matter if Qt::AA_DontUseNativeDialogs was set, both QFileDialog and QColorDialog were always unconditionally creating the platform helper at construction time: QFooDialog() -> QFooDialogPrivate::init() -> QFooDialogPrivate::platformFooHelper() -> QDialogPrivate::platformHelper() Only QFontDialog had the platformHelper() calls guarded with canBeNativeDialog(). => Move the canBeNativeDialog() check inside QDialogPrivate::platformHelper() where the platform helper instance is created. Task-number: QTBUG-55276 Change-Id: I84b595fbd009c70a3a1976ddbb32a835270c5203 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
parent
31127d390e
commit
007f92c6ee
@ -95,7 +95,7 @@ QPlatformDialogHelper *QDialogPrivate::platformHelper() const
|
||||
{
|
||||
// Delayed creation of the platform, ensuring that
|
||||
// that qobject_cast<> on the dialog works in the plugin.
|
||||
if (!m_platformHelperCreated) {
|
||||
if (!m_platformHelperCreated && canBeNativeDialog()) {
|
||||
m_platformHelperCreated = true;
|
||||
QDialogPrivate *ncThis = const_cast<QDialogPrivate *>(this);
|
||||
QDialog *dialog = ncThis->q_func();
|
||||
|
@ -2800,7 +2800,7 @@ void QFileDialogPrivate::init(const QUrl &directory, const QString &nameFilter,
|
||||
}
|
||||
|
||||
q->setAcceptMode(QFileDialog::AcceptOpen);
|
||||
nativeDialogInUse = (canBeNativeDialog() && platformFileDialogHelper() != 0);
|
||||
nativeDialogInUse = platformFileDialogHelper() != 0;
|
||||
if (!nativeDialogInUse)
|
||||
createWidgets();
|
||||
q->setFileMode(QFileDialog::AnyFile);
|
||||
|
@ -824,10 +824,8 @@ void QFontDialog::setCurrentFont(const QFont &font)
|
||||
d->strikeout->setChecked(font.strikeOut());
|
||||
d->underline->setChecked(font.underline());
|
||||
d->updateFamilies();
|
||||
if (d->canBeNativeDialog()) {
|
||||
if (QPlatformFontDialogHelper *helper = d->platformFontDialogHelper())
|
||||
helper->setCurrentFont(font);
|
||||
}
|
||||
if (QPlatformFontDialogHelper *helper = d->platformFontDialogHelper())
|
||||
helper->setCurrentFont(font);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -840,10 +838,8 @@ void QFontDialog::setCurrentFont(const QFont &font)
|
||||
QFont QFontDialog::currentFont() const
|
||||
{
|
||||
Q_D(const QFontDialog);
|
||||
if (d->canBeNativeDialog()) {
|
||||
if (const QPlatformFontDialogHelper *helper = d->platformFontDialogHelper())
|
||||
return helper->currentFont();
|
||||
}
|
||||
if (const QPlatformFontDialogHelper *helper = d->platformFontDialogHelper())
|
||||
return helper->currentFont();
|
||||
return d->sampleEdit->font();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user