Page MenuHomePhabricator

DataNode::SetName() does not trigger Modified event anymore
Closed, InvalidPublic

Description

On behalf of Trudbert Schwörer from Stryker:

The commit rMITKa095aba80ec6: Reduce name property duality (2022-06-09) modified the method mitk::DataNode::SetName(). StringProperty::SetValue() is used now to set the name of a data node which does not raise a Modified event. This caused a bug in our MITK based application which relied on a node-modified callback.

For me it was enough to move the line this->SetStringProperty("name", name);" to the top of the method. But this introduces an unrequired redundant code execution. Don't know how to fix this without violating the intention of the commit.

Event Timeline

kislinsk renamed this task from Please enter a meaningful title to DataNode::SetName() does not trigger Modified event anymore.Nov 9 2023, 8:34 PM
kislinsk triaged this task as Normal priority.
kislinsk created this task.
kislinsk closed this task as Invalid.EditedNov 9 2023, 8:54 PM

I would argue that, while it is an implicit API-change, it works as expected and intended. The commit message contains a rationale. The name is really something that should be the property of the base data rather than the data node, which is dedicated to non-persistent and typically visualization related properties. The most straight-forward solution would be to replace your call of SetName(name) with SetStringProperty("name", name) instead of changing the code of SetName(). By default, this will add the name property to the data node without falling back to a potentially existing base data property. Another solution would be to also listen to the Modified event of the BaseData or its PropertyList or even directly of its name StringProperty.