@@ -129,11 +129,10 @@ def connectNodes(self, src_port, dest_port):
129129 self ._errorIconTimer .start ()
130130
131131 def selectionChanged (self ):
132- currentSelection = self .scene ().selectedItems ()
133- previousSelection = self .scene ().previouslySelectedItems ()
134- command = CommandSelection (self .scene (), currentSelection , previousSelection )
135- self ._undoStack .push (command )
136- self .scene ().setPreviouslySelectedItems (currentSelection )
132+ current_selection = self .scene ().selectedItems ()
133+ previous_selection = self .scene ().previouslySelectedItems ()
134+ self ._undoStack .push (CommandSelection (self .scene (), current_selection , previous_selection ))
135+ self .scene ().setPreviouslySelectedItems (current_selection )
137136
138137 def nodeSelected (self , node , state ):
139138 if state and node not in self ._selectedNodes :
@@ -370,9 +369,10 @@ def mouseReleaseEvent(self, event):
370369 QtWidgets .QGraphicsView .mouseReleaseEvent (self , event )
371370 if self ._selectionStartPos :
372371 diff = event .pos () - self ._selectionStartPos
373- if diff .x () != 0 and diff .y () != 0 :
372+ selected_items = self .scene ().selectedItems ()
373+ if diff .x () != 0 and diff .y () != 0 and selected_items :
374374 self ._undoStack .beginMacro ('Move Step(s)' )
375- for item in self . scene (). selectedItems () :
375+ for item in selected_items :
376376 if item .type () == Node .Type :
377377 self ._undoStack .push (CommandMove (item , item .pos () - diff , item .pos ()))
378378 self ._undoStack .endMacro ()
0 commit comments