From 77acffb73e3cceb9700781606721d1a04957bc71 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Fri, 5 Apr 2019 19:09:15 +0200 Subject: [PATCH] Fixed crash when changing UI style (fusion, ...) * use overloaded function with string directly * Qt::QueuedConnection The old version looked correct to me, nevertheless it did always crash --- src/blackgui/components/settingsguicomponent.cpp | 2 +- src/blackgui/guiapplication.cpp | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/blackgui/components/settingsguicomponent.cpp b/src/blackgui/components/settingsguicomponent.cpp index de8c06b90..6880e0ef3 100644 --- a/src/blackgui/components/settingsguicomponent.cpp +++ b/src/blackgui/components/settingsguicomponent.cpp @@ -37,7 +37,7 @@ namespace BlackGui // Widget style connect(ui->hs_SettingsGuiOpacity, &QSlider::valueChanged, this, &CSettingsGuiComponent::changedWindowsOpacity); - connect(ui->cb_SettingsGuiWidgetStyle, qOverload(&QComboBox::currentIndexChanged), this, &CSettingsGuiComponent::widgetStyleChanged); + connect(ui->cb_SettingsGuiWidgetStyle, qOverload(&QComboBox::currentIndexChanged), this, &CSettingsGuiComponent::widgetStyleChanged, Qt::QueuedConnection); ui->comp_SettingsFonts->setStyleSheetDefaultColor(); diff --git a/src/blackgui/guiapplication.cpp b/src/blackgui/guiapplication.cpp index 4779fd00b..3e126d6ab 100644 --- a/src/blackgui/guiapplication.cpp +++ b/src/blackgui/guiapplication.cpp @@ -1086,7 +1086,15 @@ namespace BlackGui } else { - QApplication::setStyle(QStyleFactory::create(widgetStyle)); + QStyle *style = QApplication::setStyle(currentWidgetStyle); + if (style) + { + CLogMessage(this).info(u"Changed style to '%1', req.: '%2'") << style->objectName() << currentWidgetStyle; + } + else + { + CLogMessage(this).error(u"Unable to set requested style '%1'") << currentWidgetStyle; + } } } }