From 942e7076260674e9713a88c0b9dd554d0215ce5a Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 10 Jul 2020 11:25:10 -0400 Subject: [PATCH] CStringEditor: Make use of QSignalBlocker --- src/Editor/StringEditor/CStringEditor.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Editor/StringEditor/CStringEditor.cpp b/src/Editor/StringEditor/CStringEditor.cpp index 537eb035..3ffb6412 100644 --- a/src/Editor/StringEditor/CStringEditor.cpp +++ b/src/Editor/StringEditor/CStringEditor.cpp @@ -228,9 +228,11 @@ void CStringEditor::UpdateUI() if (OldStringIndex != NewStringIndex) { - pSelectionModel->blockSignals(true); - pSelectionModel->setCurrentIndex(NewStringIndex, QItemSelectionModel::ClearAndSelect); - pSelectionModel->blockSignals(false); + { + [[maybe_unused]] const QSignalBlocker blocker{pSelectionModel}; + pSelectionModel->setCurrentIndex(NewStringIndex, QItemSelectionModel::ClearAndSelect); + } + mpUI->StringNameListView->scrollTo(NewStringIndex); mpUI->StringNameListView->update(OldStringIndex); } @@ -247,9 +249,8 @@ void CStringEditor::UpdateUI() { if (mpStringTable->LanguageByIndex(LangIdx) == mCurrentLanguage) { - mpUI->EditLanguageTabBar->blockSignals(true); + [[maybe_unused]] const QSignalBlocker blocker{mpUI->EditLanguageTabBar}; mpUI->EditLanguageTabBar->setCurrentIndex(static_cast(LangIdx)); - mpUI->EditLanguageTabBar->blockSignals(false); break; } } @@ -261,16 +262,14 @@ void CStringEditor::UpdateUI() if (StringName != mpUI->StringNameLineEdit->text()) { - mpUI->StringNameLineEdit->blockSignals(true); + [[maybe_unused]] const QSignalBlocker blocker{mpUI->StringNameLineEdit}; mpUI->StringNameLineEdit->setText(StringName); - mpUI->StringNameLineEdit->blockSignals(false); } if (StringData != mpUI->StringTextEdit->toPlainText()) { - mpUI->StringTextEdit->blockSignals(true); + [[maybe_unused]] const QSignalBlocker blocker{mpUI->StringTextEdit}; mpUI->StringTextEdit->setPlainText(StringData); - mpUI->StringTextEdit->blockSignals(false); } UpdateStatusBar();