diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2022-07-07 13:39:13 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2022-07-08 10:03:32 +0200 |
commit | efbcc80010005ee62d23f6814ec5c01310abf1df (patch) | |
tree | ea66bc468145f5779aa451e11e8a9f55f7f9c811 /src/widgets/dialogs | |
parent | 13868474f9aac7a0138a1a8d226973713b46a9ba (diff) |
QFontDialog: Check if native dialog is in use before using
A call to platformFontDialogHelper() will lazily create the helper,
and is not enough to distinguish whether the helper is actually in
use. The explicit nativeDialogInUse flag also takes properties like
DontUseNativeDialog into account, which may be set after the dialog
is first constructed.
Fixes: QTBUG-104696
Pick-to: 6.2 6.3 6.4
Change-Id: Ia00a39bba4aaae8c99ae0cdd6543c2e451f72ea6
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets/dialogs')
-rw-r--r-- | src/widgets/dialogs/qfontdialog.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp index bec99b4df7..26e9212a95 100644 --- a/src/widgets/dialogs/qfontdialog.cpp +++ b/src/widgets/dialogs/qfontdialog.cpp @@ -426,10 +426,12 @@ bool QFontDialog::eventFilter(QObject *o , QEvent *e) void QFontDialogPrivate::initHelper(QPlatformDialogHelper *h) { - QFontDialog *d = q_func(); - QObject::connect(h, SIGNAL(currentFontChanged(QFont)), d, SIGNAL(currentFontChanged(QFont))); - QObject::connect(h, SIGNAL(fontSelected(QFont)), d, SIGNAL(fontSelected(QFont))); - static_cast<QPlatformFontDialogHelper *>(h)->setOptions(options); + Q_Q(QFontDialog); + auto *fontDialogHelper = static_cast<QPlatformFontDialogHelper *>(h); + fontDialogHelper->setOptions(options); + fontDialogHelper->setCurrentFont(q->currentFont()); + QObject::connect(h, SIGNAL(currentFontChanged(QFont)), q, SIGNAL(currentFontChanged(QFont))); + QObject::connect(h, SIGNAL(fontSelected(QFont)), q, SIGNAL(fontSelected(QFont))); } void QFontDialogPrivate::helperPrepareShow(QPlatformDialogHelper *) @@ -788,8 +790,11 @@ void QFontDialog::setCurrentFont(const QFont &font) d->strikeout->setChecked(font.strikeOut()); d->underline->setChecked(font.underline()); d->updateFamilies(); - if (QPlatformFontDialogHelper *helper = d->platformFontDialogHelper()) - helper->setCurrentFont(font); + + if (d->nativeDialogInUse) { + if (QPlatformFontDialogHelper *helper = d->platformFontDialogHelper()) + helper->setCurrentFont(font); + } } /*! @@ -802,8 +807,11 @@ void QFontDialog::setCurrentFont(const QFont &font) QFont QFontDialog::currentFont() const { Q_D(const QFontDialog); - if (const QPlatformFontDialogHelper *helper = d->platformFontDialogHelper()) - return helper->currentFont(); + + if (d->nativeDialogInUse) { + if (const QPlatformFontDialogHelper *helper = d->platformFontDialogHelper()) + return helper->currentFont(); + } return d->sampleEdit->font(); } |