From 96ff6e8ebe80215a0d35055c7382bb1cf58fc660 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 23 Aug 2019 09:35:20 +0200 Subject: 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 Reviewed-by: Lars Knoll --- src/gui/kernel/qguiapplication.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') 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); + } } /*! -- cgit v1.2.3