While this change retains the undo/redo command usage of the existing code, it does not use it in a way the user would expect. Doing a loop like this will cause a separate undo history entry for each selected object, so it will take  for example 10 times pressing `Ctrl+Z` to undo a property change to 10 selected objects. To solve this, `undoStack->beginMacro` could be used, but care should be taken that the name of the macro matches with the name of the change it is making.