1
0
Fork 0

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:
Richard Harrison 2017-05-20 13:40:02 +02:00
parent ee951c00e7
commit 0c4eaa8b29

View file

@ -137,6 +137,10 @@ CanvasMgr::getCanvasTexId(const simgear::canvas::CanvasPtr& canvas) const
//----------------------------------------------------------------------------
void CanvasMgr::handleModelReinit(SGPropertyNode*)
{
for(size_t i = 0; i < _elements.size(); ++i)
static_cast<sc::Canvas*>(_elements[i].get())->reloadPlacements("object");
for (size_t i = 0; i < _elements.size(); ++i)
{
sc::Canvas* element = static_cast<sc::Canvas*>(_elements[i].get());
if (element)
element->reloadPlacements("object");
}
}