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:
committed by
Automatic Release Builder
parent
6167159795
commit
fd191b51ce
@@ -28,7 +28,7 @@
|
|||||||
#include <simgear/compiler.h>
|
#include <simgear/compiler.h>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
#include <osg/AlphaFunc>
|
#include <osg/AlphaFunc>
|
||||||
#include <osg/Group>
|
#include <osg/Group>
|
||||||
@@ -103,10 +103,12 @@ SGMatModel::get_model_count( SGPropertyNode *prop_root )
|
|||||||
inline void
|
inline void
|
||||||
SGMatModel::load_models( SGPropertyNode *prop_root )
|
SGMatModel::load_models( SGPropertyNode *prop_root )
|
||||||
{
|
{
|
||||||
|
std::lock_guard<std::mutex> g(_loadMutex);
|
||||||
|
|
||||||
// Load model only on demand
|
// Load model only on demand
|
||||||
if (!_models_loaded) {
|
if (!_models_loaded) {
|
||||||
for (unsigned int i = 0; i < _paths.size(); i++) {
|
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) {
|
if (entity != 0) {
|
||||||
// FIXME: this stuff can be handled
|
// FIXME: this stuff can be handled
|
||||||
// in the XML wrapper as well (at least,
|
// in the XML wrapper as well (at least,
|
||||||
|
|||||||
@@ -149,6 +149,8 @@ private:
|
|||||||
double _spacing_m;
|
double _spacing_m;
|
||||||
double _range_m;
|
double _range_m;
|
||||||
HeadingType _heading_type;
|
HeadingType _heading_type;
|
||||||
|
|
||||||
|
std::mutex _loadMutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user