Hi,
I wonder if it's my setup or not, but as of
1704779f6bd2f973b095a5bbdbd7a413f58e8910 (windowing: Move code to new
WindowManager class.) MyPaint stopped working on fresh config. It
fails like this:
Traceback (most recent call last):
File "./mypaint", line 130, in <module>
main.main(datapath, confpath)
File "/home/giniu/dev/mypaint/gui/main.py", line 68, in main
run()
File "/home/giniu/dev/mypaint/gui/main.py", line 43, in run
app = application.Application(datapath, confpath, args)
File "/home/giniu/dev/mypaint/gui/application.py", line 66, in __init__
self.windowmanager = windowing.WindowManager(self)
File "/home/giniu/dev/mypaint/gui/windowing.py", line 267, in __init__
self.main_window = self.get_window('drawWindow')
File "/home/giniu/dev/mypaint/gui/windowing.py", line 286, in get_window
using_default = self.load_window_position(window_name, window)
File "/home/giniu/dev/mypaint/gui/windowing.py", line 319, in
load_window_position
f.close()
UnboundLocalError: local variable 'f' referenced before assignment
it happened when I removed ~/.mypaint and wanted to see how fresh
setup behaves, thus file ~/.mypaint/windowpos.conf does not exists for
me. I believe it should work as I look at it, at least it should
according to PEP341 that was merged into Python 5 years ago? Unwinding
the try-except-finally of PEP341 into try-try-except-finally works...
funny, isn't it? That's with latest Python 2.7, they changed something
and it worked with previous versions, or maybe there is mistake in
code that I didn't noticed? Didn't had time to test it out so I'm not
sure if it's bug or not so I'm not sending it to bugtracker but list.
Anyway, I attached patch that made it work for me.
Cheers,
Andrzej.
diff --git a/gui/windowing.py b/gui/windowing.py
index a502d1a..42e938a 100644
--- a/gui/windowing.py
+++ b/gui/windowing.py
@@ -303,20 +303,24 @@ class WindowManager(object):
def load_window_position(self, name, window):
geometry, visible = WINDOW_DEFAULTS.get(name, (None, False))
using_default = True
+ f = None
try:
- f = open(self.config_file_path)
- for line in f:
- if line.startswith(name):
- parts = line.split()
- visible = parts[1] == 'True'
- x, y, w, h = [int(i) for i in parts[2:2+4]]
- geometry = '%dx%d+%d+%d' % (w, h, x, y)
- using_default = False
- break
- except IOError:
- pass
+ try:
+ print self.config_file_path
+ f = open(self.config_file_path)
+ for line in f:
+ if line.startswith(name):
+ parts = line.split()
+ visible = parts[1] == 'True'
+ x, y, w, h = [int(i) for i in parts[2:2+4]]
+ geometry = '%dx%d+%d+%d' % (w, h, x, y)
+ using_default = False
+ break
+ except IOError:
+ pass
finally:
- f.close()
+ if f:
+ f.close()
# Initial gravities can be all over the place. Fix aberrant ones up
# when the windows are safely on-screen so their position can be
# saved sanely. Doing this only when the window's mapped means that the
_______________________________________________
Mypaint-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/mypaint-discuss