Check if items having events sent to are still in the scene (#919)

Check if items having events sent to are still in the scene
This commit is contained in:
Ogi Moore 2019-06-19 22:08:54 -07:00 committed by GitHub
parent 9b8ef188a5
commit 2f4ac51a11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -263,6 +263,7 @@ class GraphicsScene(QtGui.QGraphicsScene):
for item in prevItems: for item in prevItems:
event.currentItem = item event.currentItem = item
try: try:
if item.scene() is self:
item.hoverEvent(event) item.hoverEvent(event)
except: except:
debug.printExc("Error sending hover exit event:") debug.printExc("Error sending hover exit event:")
@ -288,7 +289,7 @@ class GraphicsScene(QtGui.QGraphicsScene):
else: else:
acceptedItem = None acceptedItem = None
if acceptedItem is not None: if acceptedItem is not None and acceptedItem.scene() is self:
#print "Drag -> pre-selected item:", acceptedItem #print "Drag -> pre-selected item:", acceptedItem
self.dragItem = acceptedItem self.dragItem = acceptedItem
event.currentItem = self.dragItem event.currentItem = self.dragItem
@ -435,6 +436,8 @@ class GraphicsScene(QtGui.QGraphicsScene):
for item in items: for item in items:
if hoverable and not hasattr(item, 'hoverEvent'): if hoverable and not hasattr(item, 'hoverEvent'):
continue continue
if item.scene() is not self:
continue
shape = item.shape() # Note: default shape() returns boundingRect() shape = item.shape() # Note: default shape() returns boundingRect()
if shape is None: if shape is None:
continue continue