FlatCAMDraw is responding to key press when inactive.

Issue #95 resolved
Juan Pablo Caram repo owner created an issue

The following error was thrown when hitting a key on the keyboard while having focus on the plot just after starting the program:

[DEBUG][Dummy-1] FlatCAM is up to date!
[DEBUG][MainThread] button=1, x=137, y=199, xdata=0.042453, ydata=0.328302
[DEBUG][MainThread] No active tool to respond to click!
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_qt5.py", line 315, in keyPressEvent
    FigureCanvasBase.key_press_event(self, key)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/backend_bases.py", line 1816, in key_press_event
    self.callbacks.process(s, event)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/cbook.py", line 540, in process
    proxy(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/cbook.py", line 415, in __call__
    return mtd(*args, **kwargs)
  File "/home/jpcaram/flatcam/FlatCAMDraw.py", line 937, in on_canvas_key
    response = self.active_tool.on_key(event.key)
AttributeError: 'NoneType' object has no attribute 'on_key'

Action items:

  • Catch the error or prevent it when no tool is active.
  • Or, make sure no FlatCAMDraw instance is around when not "active".

Comments (2)

  1. Juan Pablo Caram reporter

    This was causing issue #93 by preventing the code to reach the other event handlers when the exception is raised.

    The exception has been prevented in the code.

  2. Juan Pablo Caram reporter

    There is in fact a unique instance of FlatCAMDraw. Added activation/deactivation code taking care of the signals and callbacks. Commit 8da39d5.

  3. Log in to comment