Checking if view is alive before returning it.

This commit is contained in:
fabioz 2014-03-13 15:52:49 -03:00
parent 1edf1375ed
commit e46bb31449

View File

@ -5,6 +5,10 @@ from .. import functions as fn
import weakref import weakref
import operator import operator
from ..util.lru_cache import LRUCache from ..util.lru_cache import LRUCache
from pyqtgraph.Qt import USE_PYSIDE
if USE_PYSIDE:
from PySide import shiboken
class GraphicsItem(object): class GraphicsItem(object):
@ -53,7 +57,13 @@ class GraphicsItem(object):
if len(views) < 1: if len(views) < 1:
return None return None
self._viewWidget = weakref.ref(self.scene().views()[0]) self._viewWidget = weakref.ref(self.scene().views()[0])
return self._viewWidget()
v = self._viewWidget()
if USE_PYSIDE:
if not shiboken.isValid(v):
return None
return v
def forgetViewWidget(self): def forgetViewWidget(self):
self._viewWidget = None self._viewWidget = None