Skip to content

Commit

Permalink
BUG: Fix applySettings() to emit "settingChanged()" only if needed
Browse files Browse the repository at this point in the history
Further improve the fix integrated in c8ce0de ("BUG: Fix incorrect changed
settings indicator", 2018-07-04) and update ctkSettingsPanelTest1 accordingly.
  • Loading branch information
jcfr authored and jamesobutler committed Jan 16, 2024
1 parent fff6977 commit b83ff7a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions Libs/Widgets/Testing/Cpp/ctkSettingsPanelTest1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ int TestStringList(ctkSettingsPanelForTest& settingsPanel)
CHECK_QSTRINGLIST(settingsPanel.myDefaultPropertyValue("key list").toStringList(), QStringList());
CHECK_QSTRINGLIST(settingsPanel.myPropertyValue("key list").toStringList(), QStringList() << "first item");
CHECK_QSTRINGLIST(settingsPanel.changedSettings(), QStringList());
CHECK_INT(spy.count(), 0);
CHECK_INT(spy.count(), 1);

// Reset spy
spy.clear();
Expand Down Expand Up @@ -386,7 +386,7 @@ int TestStringList(ctkSettingsPanelForTest& settingsPanel)
CHECK_QSTRINGLIST(settingsPanel.myDefaultPropertyValue("key list").toStringList(), QStringList());
CHECK_QSTRINGLIST(settingsPanel.myPropertyValue("key list").toStringList(), QStringList() << "first item" << "second item");
CHECK_QSTRINGLIST(settingsPanel.changedSettings(), QStringList());
CHECK_INT(spy.count(), 0);
CHECK_INT(spy.count(), 1);

// Reset spy
spy.clear();
Expand Down Expand Up @@ -418,7 +418,7 @@ int TestStringList(ctkSettingsPanelForTest& settingsPanel)
CHECK_QSTRINGLIST(settingsPanel.myDefaultPropertyValue("key list").toStringList(), QStringList());
CHECK_QSTRINGLIST(settingsPanel.myPropertyValue("key list").toStringList(), QStringList());
CHECK_QSTRINGLIST(settingsPanel.changedSettings(), QStringList());
CHECK_INT(spy.count(), 0);
CHECK_INT(spy.count(), 1);

// Reset spy
spy.clear();
Expand Down
7 changes: 5 additions & 2 deletions Libs/Widgets/ctkSettingsPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,11 @@ void ctkSettingsPanel::applySettings()
foreach(const QString& key, d->Properties.keys())
{
PropertyType& prop = d->Properties[key];
prop.setPreviousValue(prop.value());
emit settingChanged(key, prop.value());
if (prop.previousValue() != prop.value())
{
prop.setPreviousValue(prop.value());
emit settingChanged(key, prop.value());
}
}
}

Expand Down

0 comments on commit b83ff7a

Please sign in to comment.