MouseClickEvent: sometimes __repr__ could cause an exception

This happens during debugging session in an IDE (eric5) when debugger inspects
variables but self._scenePos is not yet initialized.
This commit is contained in:
Mikhail Terekhov 2014-02-26 10:20:24 -05:00
parent ab0729bb04
commit 6255dca99c

View File

@ -221,9 +221,12 @@ class MouseClickEvent(object):
return self._modifiers
def __repr__(self):
p = self.pos()
return "<MouseClickEvent (%g,%g) button=%d>" % (p.x(), p.y(), int(self.button()))
try:
p = self.pos()
return "<MouseClickEvent (%g,%g) button=%d>" % (p.x(), p.y(), int(self.button()))
except:
return "<MouseClickEvent button=%d>" % (int(self.button()))
def time(self):
return self._time