diff --git a/launcher/languages.cpp b/launcher/languages.cpp index 670faa345..8dcd86d39 100644 --- a/launcher/languages.cpp +++ b/launcher/languages.cpp @@ -86,7 +86,7 @@ QString Languages::generateLanguageName(const Languages::Options & language) void Languages::fillLanguages(QComboBox * widget, bool includeAll) { - widget->blockSignals(true); // we do not want calls caused by initialization + QSignalBlocker guard(widget); // we do not want calls caused by initialization widget->clear(); std::string activeLanguage = includeAll ? @@ -115,13 +115,11 @@ void Languages::fillLanguages(QComboBox * widget, bool includeAll) if(activeLanguage == language.identifier) widget->setCurrentIndex(widget->count() - 1); } - - widget->blockSignals(false); } void Languages::fillLanguages(QListWidget * widget, bool includeAll) { - widget->blockSignals(true); // we do not want calls caused by initialization + QSignalBlocker guard(widget); // we do not want calls caused by initialization widget->clear(); std::string activeLanguage = includeAll ? @@ -154,5 +152,4 @@ void Languages::fillLanguages(QListWidget * widget, bool includeAll) if(activeLanguage == language.identifier) widget->setCurrentRow(widget->count() - 1); } - widget->blockSignals(false); } diff --git a/launcher/settingsView/csettingsview_moc.cpp b/launcher/settingsView/csettingsview_moc.cpp index 67a3ec199..3d21018f4 100644 --- a/launcher/settingsView/csettingsview_moc.cpp +++ b/launcher/settingsView/csettingsview_moc.cpp @@ -216,7 +216,8 @@ static QVector findAvailableResolutions(int displayIndex) void CSettingsView::fillValidResolutionsForScreen(int screenIndex) { - ui->comboBoxResolution->blockSignals(true); // avoid saving wrong resolution after adding first item from the list + QSignalBlocker guard(ui->comboBoxResolution); // avoid saving wrong resolution after adding first item from the list + ui->comboBoxResolution->clear(); bool fullscreen = settings["video"]["fullscreen"].Bool(); @@ -243,13 +244,12 @@ void CSettingsView::fillValidResolutionsForScreen(int screenIndex) // if selected resolution no longer exists, force update value to the largest (last) resolution if(resIndex == -1) ui->comboBoxResolution->setCurrentIndex(ui->comboBoxResolution->count() - 1); - - ui->comboBoxResolution->blockSignals(false); } void CSettingsView::fillValidRenderers() { - ui->comboBoxRendererType->blockSignals(true); // avoid saving wrong resolution after adding first item from the list + QSignalBlocker guard(ui->comboBoxRendererType); // avoid saving wrong renderer after adding first item from the list + ui->comboBoxRendererType->clear(); auto driversList = getAvailableRenderingDrivers(); @@ -259,8 +259,6 @@ void CSettingsView::fillValidRenderers() int index = ui->comboBoxRendererType->findText(QString::fromStdString(rendererName)); ui->comboBoxRendererType->setCurrentIndex(index); - - ui->comboBoxRendererType->blockSignals(false); } #else void CSettingsView::fillValidResolutionsForScreen(int screenIndex)