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