Update GraphicsScene.py (#599)
In lines 174 and 191 cev[0] is being accessed when cev is an empty list. I get this error when inheriting from GraphicsLayoutWidget and overloading mouseDoubleClickEvent.
This commit is contained in:
parent
bbc11b96a9
commit
e3884ebd20
|
@ -183,7 +183,9 @@ class GraphicsScene(QtGui.QGraphicsScene):
|
||||||
if int(ev.buttons() & btn) == 0:
|
if int(ev.buttons() & btn) == 0:
|
||||||
continue
|
continue
|
||||||
if int(btn) not in self.dragButtons: ## see if we've dragged far enough yet
|
if int(btn) not in self.dragButtons: ## see if we've dragged far enough yet
|
||||||
cev = [e for e in self.clickEvents if int(e.button()) == int(btn)][0]
|
cev = [e for e in self.clickEvents if int(e.button()) == int(btn)]
|
||||||
|
if cev:
|
||||||
|
cev = cev[0]
|
||||||
dist = Point(ev.scenePos() - cev.scenePos()).length()
|
dist = Point(ev.scenePos() - cev.scenePos()).length()
|
||||||
if dist == 0 or (dist < self._moveDistance and now - cev.time() < self.minDragTime):
|
if dist == 0 or (dist < self._moveDistance and now - cev.time() < self.minDragTime):
|
||||||
continue
|
continue
|
||||||
|
@ -208,6 +210,7 @@ class GraphicsScene(QtGui.QGraphicsScene):
|
||||||
self.dragButtons.remove(ev.button())
|
self.dragButtons.remove(ev.button())
|
||||||
else:
|
else:
|
||||||
cev = [e for e in self.clickEvents if int(e.button()) == int(ev.button())]
|
cev = [e for e in self.clickEvents if int(e.button()) == int(ev.button())]
|
||||||
|
if cev:
|
||||||
if self.sendClickEvent(cev[0]):
|
if self.sendClickEvent(cev[0]):
|
||||||
#print "sent click event"
|
#print "sent click event"
|
||||||
ev.accept()
|
ev.accept()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user