Only do Label Change notification if the label truly changes

The code for setting the value of a Label property would do a quick return if the new label was equal to the current one, but otherwise the proposed new label might be modified to make it unique. If the modified new value were equal to the current value, a Change notification would still be generated. This no longer occurs.
This commit is contained in:
Kevin Martin
2025-03-05 13:36:35 -05:00
parent bf55e4e258
commit a0d0fc1498

View File

@@ -1425,23 +1425,27 @@ PropertyString::PropertyString() = default;
PropertyString::~PropertyString() = default;
void PropertyString::setValue(const char* newLabel)
void PropertyString::setValue(const char* newValue)
{
if (!newLabel) {
if (!newValue) {
return;
}
if (_cValue == newLabel) {
if (_cValue == newValue) {
return;
}
std::vector<std::pair<Property*, std::unique_ptr<Property>>> propChanges;
std::string label = newLabel;
std::string newValueStr = newValue;
auto obj = dynamic_cast<DocumentObject*>(getContainer());
bool commit = false;
if (obj && this == &obj->Label) {
propChanges = obj->onProposedLabelChange(label);
propChanges = obj->onProposedLabelChange(newValueStr);
if (_cValue == newValueStr) {
// OnProposedLabelChange has changed the new value to what the current value is
return;
}
if (!propChanges.empty() && !GetApplication().getActiveTransaction()) {
commit = true;
std::ostringstream str;
@@ -1451,7 +1455,7 @@ void PropertyString::setValue(const char* newLabel)
}
aboutToSetValue();
_cValue = label;
_cValue = newValueStr;
hasSetValue();
for (auto& change : propChanges) {