@@ -352,6 +352,10 @@ def set_property(self, name, value, push_undo=True):
352352 """
353353 Set the value on the node custom property.
354354
355+ Note:
356+ When setting the node ``"name"`` property a new unique name will be
357+ used if another node in the graph has the same node name.
358+
355359 Args:
356360 name (str): name of the property.
357361 value (object): property data (python built in types).
@@ -362,16 +366,22 @@ def set_property(self, name, value, push_undo=True):
362366 if self .get_property (name ) == value :
363367 return
364368
369+ # prevent nodes from have the same name.
365370 if self .graph and name == 'name' :
366371 value = self .graph .get_unique_name (value )
367372 self .NODE_NAME = value
368373
369374 if self .graph :
375+ undo_cmd = PropertyChangedCmd (self , name , value )
376+ if name == 'name' :
377+ undo_cmd .setText (
378+ 'renamed "{}" to "{}"' .format (self .name (), value )
379+ )
370380 if push_undo :
371381 undo_stack = self .graph .undo_stack ()
372- undo_stack .push (PropertyChangedCmd ( self , name , value ) )
382+ undo_stack .push (undo_cmd )
373383 else :
374- PropertyChangedCmd ( self , name , value ) .redo ()
384+ undo_cmd .redo ()
375385 else :
376386 if hasattr (self .view , name ):
377387 setattr (self .view , name , value )
0 commit comments