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,6 +103,8 @@ 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++) {
|
||||||
|
@ -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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user