phrack / ShootOFF-legacy

An open source framework to enhance laser dry fire training.
BSD 4-Clause "Original" or "Old" License
30 stars 17 forks source link

Exception when saving target from target editor with many overlapping shapes #57

Closed cbdmaul closed 10 years ago

cbdmaul commented 10 years ago

Exception in Tkinter callback Traceback (most recent call last): File "C:\Python27\lib\lib-tk\Tkinter.py", line 1470, in call return self.func(*args) File "C:\Users\xxx\Documents\ShootOFF\ShootOFF-github\target_editor.py", line 34, in save_targ et self._target_canvas) File "C:\Users\xxx\Documents\ShootOFF\ShootOFF-github\target_pickler.py", line 13, in save region_coords = canvas.coords(region) File "C:\Python27\lib\lib-tk\Tkinter.py", line 2240, in coords self.tk.call((self._w, 'coords') + args))) TclError: wrong # args: should be ".62210568L.39562696L.39562824L.39745480L coords tagOrId ?x y x y ...?"

I'll email you a pic of the target

cbdmaul commented 10 years ago

As a consequence, the targets are not saved to file but are added to the target menu, which when clicked generate this exception:

Exception in Tkinter callback Traceback (most recent call last): File "C:\Python27\lib\lib-tk\Tkinter.py", line 1470, in call return self.func(*args) File "shootoff.py", line 560, in return lambda: func(name) File "shootoff.py", line 262, in add_target name, self._webcam_canvas, target_name) File "C:\Users\xxx\Documents\ShootOFF\ShootOFF-github\target_pickler.py", line 31, in load target = open(target_file, 'rb') IOError: [Errno 2] No such file or directory: u'C:/Users/xxx/Documents/ShootOFF/ShootOFF-github/ targets/test.target'

phrack commented 10 years ago

I've replicated this on Windows and Linux. The easiest way to replicate it is to open the Target Editor, click any shape, and add it to the same spot twice by double clicking. Saving the target will produce the first exception. I've mitigated the second exception by not adding the target to the menus unless the file was actually saved.

One interesting clue is that if you click, wait a few second, and click again without moving the mouse, you should have two shapes in exactly the same place. However, if you select one them and hit delete, there are no more shapes in that location, meaning the second wasn't actually created. I think there might be a bug in Tcl that causes the second shape to not actually be created (see: http://savannah.nongnu.org/bugs/?22426). There may be a way to detect this condition and prevent the exception. Otherwise, there may be no choice but to catch the first exception and warn the user.