Skip to content

Commit ff1d961

Browse files
committed
Prevent signal recursion when canceling group change
Use explicit disconnect/connect of the signal handler when resetting combobox text to prevent recursion in selectedGroupChanged.
1 parent 90278e1 commit ff1d961

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/lib/configwidgetslib/impage.cpp

+16-6
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,22 @@ void IMPage::selectedGroupChanged() {
201201
return;
202202
}
203203
if (!config_->currentGroup().isEmpty() && config_->needSave()) {
204-
if (QMessageBox::No ==
205-
QMessageBox::question(this, _("Current group changed"),
206-
_("Do you want to change group? Changes to "
207-
"current group will be lost!"))) {
208-
ui_->inputMethodGroupComboBox->setCurrentText(
209-
config_->currentGroup());
204+
if (QMessageBox::No == QMessageBox::question(
205+
this, _("Current group changed"),
206+
_("Do you want to change group? Changes to current group will be "
207+
"lost!"))) {
208+
// Temporarily disconnect our signal handler
209+
QMetaObject::Connection connection =
210+
disconnect(ui_->inputMethodGroupComboBox,
211+
&QComboBox::currentTextChanged, this,
212+
&IMPage::selectedGroupChanged);
213+
ui_->inputMethodGroupComboBox->setCurrentText(config_->currentGroup());
214+
// Restore our signal handler
215+
if (connection) {
216+
connect(ui_->inputMethodGroupComboBox,
217+
&QComboBox::currentTextChanged, this,
218+
&IMPage::selectedGroupChanged);
219+
}
210220
return;
211221
}
212222
}

0 commit comments

Comments
 (0)