Avoid a race in MatModels loading
Add a mutex to ensure an SGMatModels only loads its models once. Caught be ASan, hurrah.
This commit is contained in:
parent
b874201806
commit
297e509576
@ -103,10 +103,12 @@ SGMatModel::get_model_count( SGPropertyNode *prop_root )
|
||||
inline void
|
||||
SGMatModel::load_models( SGPropertyNode *prop_root )
|
||||
{
|
||||
std::lock_guard<std::mutex> g(_loadMutex);
|
||||
|
||||
// Load model only on demand
|
||||
if (!_models_loaded) {
|
||||
for (unsigned int i = 0; i < _paths.size(); i++) {
|
||||
osg::Node *entity = SGModelLib::loadModel(_paths[i], prop_root);
|
||||
osg::Node* entity = SGModelLib::loadModel(_paths[i], prop_root);
|
||||
if (entity != 0) {
|
||||
// FIXME: this stuff can be handled
|
||||
// in the XML wrapper as well (at least,
|
||||
|
@ -149,6 +149,8 @@ private:
|
||||
double _spacing_m;
|
||||
double _range_m;
|
||||
HeadingType _heading_type;
|
||||
|
||||
std::mutex _loadMutex;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user