wonderworks-software/PyFlow

New File button breaks the editor

EtienneDesticourt opened this issue · 2 comments

Hi,

When clicking the New File button in the File menu, there is no feedback that anything has happened and after doing so adding any node to the canvas will raise an attribute error.

Traceback (most recent call last):
  File "F:\PyFlow\PyFlow\UI\Widgets\BlueprintCanvas.py", line 1389, in dragEnterEvent
    self.tempnode = self._createNode(nodeTemplate)
  File "F:\PyFlow\PyFlow\UI\Widgets\BlueprintCanvas.py", line 1558, in _createNode
    nodeInstance = getNodeInstance(jsonTemplate, self)
  File "F:\PyFlow\PyFlow\UI\Widgets\BlueprintCanvas.py", line 80, in getNodeInstance
    canvas.addNode(instance, jsonTemplate, parentGraph=parentGraph)
  File "F:\PyFlow\PyFlow\UI\Widgets\BlueprintCanvas.py", line 1668, in addNode
    self.graphManager.activeGraph().addNode(uiNode._rawNode, jsonTemplate)
AttributeError: 'NoneType' object has no attribute 'addNode'

Other issues will also appear such as:

  • New nodes automatically spawn in the center when they're placed elsewhere on the canvas
  • New nodes are created two at a time when placed on the canvas
  • Multi-node rectangle selection no longer selects anything
  • The right-click node search menu will sometimes stay open permanently despite clicking elsewhere (I have encountered it once but haven't been able to reproduce it since, might be another issue.)
  • No popup menu appears warning that data will be lost

This was tested on the latest commit (3a39375) of the master branch.

Steps to reproduce:

  • Clone the master branch
  • Create a new python 3.6 virtual environment and activate it
  • install requirements-standalone.txt with pip
  • launch with python pyflow.py
  • Click File -> New File
  • Right-Click the canvas
  • Search 'int' in the search bar
  • Drag and drop the 'makeInt' node to the canvas somewhere away from the canvas center
  • The error appears in the console
  • Two 'makeInt' nodes should have appeared in the center, one on top of the other
  • Drag the top node away from the center
  • Attempt to do a rectangle selection over the two nodes
  • Close the PyFlow window

Very cool project otherwise, looking forward to trying it out further and hope you don't mind the issue spam =)!

@EtienneDesticourt no prob) Can you describe step by step repro? All this issues are because of New File does something weird

Sure thing, I've added the steps to the top comment.
Also I've changed the description of the popup menu bug. If you add nodes to the file that's open by default when opening PyFlow you get an "unsaved data" popup menu upon closing but if you add nodes to a new file (and no nodes were previously added to the default file) you won't get a popup menu upon closing.