Canvas exception during re-init.
Add defensive logic to ensure that a null pointer isn't dereferenced. This happened to me once or twice during a reinit (Location/Position In Air to the current position). It may be related to the model, but in any case the code needs to ensure that the static cast failure is handled correctly.
This commit is contained in:
parent
ee951c00e7
commit
0c4eaa8b29
1 changed files with 6 additions and 2 deletions
|
@ -137,6 +137,10 @@ CanvasMgr::getCanvasTexId(const simgear::canvas::CanvasPtr& canvas) const
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void CanvasMgr::handleModelReinit(SGPropertyNode*)
|
void CanvasMgr::handleModelReinit(SGPropertyNode*)
|
||||||
{
|
{
|
||||||
for(size_t i = 0; i < _elements.size(); ++i)
|
for (size_t i = 0; i < _elements.size(); ++i)
|
||||||
static_cast<sc::Canvas*>(_elements[i].get())->reloadPlacements("object");
|
{
|
||||||
|
sc::Canvas* element = static_cast<sc::Canvas*>(_elements[i].get());
|
||||||
|
if (element)
|
||||||
|
element->reloadPlacements("object");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue