Draft: Fixes error in Draft trackers when not on a 3D view
This commit is contained in:
committed by
Yorik van Havre
parent
5d87b26a91
commit
8ef66ad73d
@@ -89,13 +89,24 @@ class Tracker:
|
||||
ToDo.delay(self._removeSwitch, self.switch)
|
||||
self.switch = None
|
||||
|
||||
def getSceneGraph(self):
|
||||
"""Returns the current scenegraph or None if this is not a 3D view
|
||||
"""
|
||||
v = Draft.get3DView()
|
||||
if v:
|
||||
return v.getSceneGraph()
|
||||
else:
|
||||
return None
|
||||
|
||||
def _insertSwitch(self, switch):
|
||||
"""Insert self.switch into the scene graph.
|
||||
|
||||
Must not be called
|
||||
from an event handler (or other scene graph traversal).
|
||||
"""
|
||||
sg = Draft.get3DView().getSceneGraph()
|
||||
sg = self.getSceneGraph()
|
||||
if not sg:
|
||||
return
|
||||
if self.ontop:
|
||||
sg.insertChild(switch, 0)
|
||||
else:
|
||||
@@ -107,7 +118,9 @@ class Tracker:
|
||||
As with _insertSwitch,
|
||||
must not be called during scene graph traversal).
|
||||
"""
|
||||
sg = Draft.get3DView().getSceneGraph()
|
||||
sg = self.getSceneGraph()
|
||||
if not sg:
|
||||
return
|
||||
if sg.findChild(switch) >= 0:
|
||||
sg.removeChild(switch)
|
||||
|
||||
@@ -127,7 +140,9 @@ class Tracker:
|
||||
So it doesn't obscure the other objects.
|
||||
"""
|
||||
if self.switch:
|
||||
sg = Draft.get3DView().getSceneGraph()
|
||||
sg = self.getSceneGraph()
|
||||
if not sg:
|
||||
return
|
||||
sg.removeChild(self.switch)
|
||||
sg.addChild(self.switch)
|
||||
|
||||
@@ -137,7 +152,9 @@ class Tracker:
|
||||
So it obscures the other objects.
|
||||
"""
|
||||
if self.switch:
|
||||
sg = Draft.get3DView().getSceneGraph()
|
||||
sg = self.getSceneGraph()
|
||||
if not sg:
|
||||
return
|
||||
sg.removeChild(self.switch)
|
||||
sg.insertChild(self.switch, 0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user