diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2019-08-23 09:35:20 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2019-08-23 10:39:43 +0200 |
commit | 96ff6e8ebe80215a0d35055c7382bb1cf58fc660 (patch) | |
tree | 9f4bc5af1205d2908c8616bccfc033e8ba14f83a /src | |
parent | b1db1dd655788fb685949959c99c901515bfd8ab (diff) |
QGuiApplication: drop mutex before emitting fontChanged()
Emitting a signal executes an unknowable amount of code. We shouldn't
hold a mutex while doing so. E.g., if the signal emission causes
another call to QGuiApplication::setFont(), the old code would
deadlock, since applicationFontMutex is not recursive.
Fix by taking a copy of the application font under mutex protection,
then dropping the lock for the emission of the signal.
Change-Id: Ib2569b3a08af6ef5f38459a19f74cb0db27b7772
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 5014878bd2..359d182dd9 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -3284,8 +3284,11 @@ void QGuiApplication::setFont(const QFont &font) *QGuiApplicationPrivate::app_font = font; applicationResourceFlags |= ApplicationFontExplicitlySet; - if (emitChange && qGuiApp) - emit qGuiApp->fontChanged(*QGuiApplicationPrivate::app_font); + if (emitChange && qGuiApp) { + auto font = *QGuiApplicationPrivate::app_font; + locker.unlock(); + emit qGuiApp->fontChanged(font); + } } /*! |