workaround broken QFontDialog on macOS with Qt5 (Fixes #20426)

QFontDialog using the native dialog is broken in some versions of
Qt5 on macOS, see
  - https://bugreports.qt.io/browse/QTBUG-69878
  - https://successfulsoftware.net/2018/11/02/qt-is-broken-on-macos-right-now/

this breaks QgsFontButton in ModeQFont. When opening the dialog it will
not change the format after accepting.

normally our code wouldn't use the native dialog on macOS anyway,
but due to using an outdated preprocessor check it was exhibiting
the broken behavior.

this patch restores the usage of a non-native font dialog on macOS.

discussions:
- https://issues.qgis.org/issues/20426
- https://github.com/qgis/QGIS/pull/8585
This commit is contained in:
iona5 2018-12-04 12:08:22 +01:00 committed by Peter Petrik
parent a1dbb96110
commit 930c56f5b8

View File

@ -195,9 +195,12 @@ namespace QgsGuiUtils
// parent is intentionally not set to 'this' as
// that would make it follow the style sheet font
// see also #12233 and #4937
#if defined(Q_OS_MAC) && defined(QT_MAC_USE_COCOA)
// Native Mac dialog works only for Qt Carbon
return QFontDialog::getFont( &ok, initial, 0, title, QFontDialog::DontUseNativeDialog );
#if defined(Q_OS_MAC)
// Native dialog broken on macOS with Qt5
// probably only broken in Qt5.11.1 and .2
// (see https://successfulsoftware.net/2018/11/02/qt-is-broken-on-macos-right-now/ )
// possible upstream bug: https://bugreports.qt.io/browse/QTBUG-69878 (fixed in Qt 5.12 ?)
return QFontDialog::getFont( &ok, initial, nullptr, title, QFontDialog::DontUseNativeDialog );
#else
return QFontDialog::getFont( &ok, initial, nullptr, title );
#endif