Commit 40cb0d6557e49ee42406fecdf8a2ea33c5709cfd
1 parent
0f477c67
Make cube loading thread save by putting an OpenMP critical directive around the call to load.
Showing
1 changed file
with
5 additions
and
2 deletions
src/model/GModelSpatialDiffuseCube.cpp
| ... | ... | @@ -1033,13 +1033,16 @@ void GModelSpatialDiffuseCube::free_members(void) |
| 1033 | 1033 | /***********************************************************************//** |
| 1034 | 1034 | * @brief Fetch cube |
| 1035 | 1035 | * |
| 1036 | - * Load diffuse cube if it is not yet loaded. | |
| 1036 | + * Load diffuse cube if it is not yet loaded. The loading is thread save. | |
| 1037 | 1037 | ***************************************************************************/ |
| 1038 | 1038 | void GModelSpatialDiffuseCube::fetch_cube(void) const |
| 1039 | 1039 | { |
| 1040 | 1040 | // Load cube if it is not yet loaded |
| 1041 | 1041 | if (!m_loaded && !m_filename.empty()) { |
| 1042 | - const_cast<GModelSpatialDiffuseCube*>(this)->load(m_filename); | |
| 1042 | + #pragma omp critical | |
| 1043 | + { | |
| 1044 | + const_cast<GModelSpatialDiffuseCube*>(this)->load(m_filename); | |
| 1045 | + } | |
| 1043 | 1046 | } |
| 1044 | 1047 | |
| 1045 | 1048 | // Return | ... | ... |