1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

Use QSignalBlocker in launcher where applicable

This commit is contained in:
Ivan Savenko 2024-01-05 22:06:07 +02:00
parent 0584591e01
commit 0acf65af17
2 changed files with 6 additions and 11 deletions

View File

@ -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);
}

View File

@ -216,7 +216,8 @@ static QVector<QSize> 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)