@@ -104,10 +104,11 @@ XPLMObjectRef CSLObj::GetAndLoadObj ()
104
104
105
105
// Determine which file to load and if we need a copied .obj file
106
106
// / @details 1. Determine if we need to access a copied file at all
107
- // / 2. Compute that copied file name
107
+ // / 2. Avoid double-execution by testing if the file name is one for a copied file already
108
+ // / 3. Compute that copied file name
108
109
// / It will include one of the texture ids if texture replacement is involved
109
110
// / It will always end on ".xpmp2.obj"
110
- // / 3 . Test if that copied file already exists
111
+ // / 4 . Test if that copied file already exists
111
112
// / The actual copy operation will only be peformed upon load.
112
113
void CSLObj::DetermineWhichObjToLoad ()
113
114
{
@@ -116,7 +117,11 @@ void CSLObj::DetermineWhichObjToLoad ()
116
117
if (!glob.bObjReplDataRefs && !bDoReplTextures)
117
118
return ;
118
119
119
- // 2. Compute that copied file name
120
+ // 2. Test if this determination has previously already led to a copied file name
121
+ if (path.find (" .xpmp2.obj" ) != std::string::npos)
122
+ return ;
123
+
124
+ // 3. Compute that copied file name
120
125
pathOrig = path; // Save the original name
121
126
// remove the current extension
122
127
RemoveExtension (path);
@@ -130,7 +135,7 @@ void CSLObj::DetermineWhichObjToLoad ()
130
135
// always add 'xpmp2.obj' as the final extension
131
136
path += " .xpmp2.obj" ;
132
137
133
- // 3 . Test if that copied file already exists
138
+ // 4 . Test if that copied file already exists
134
139
if (ExistsFile (path))
135
140
// It does exist, so no new copy is needed
136
141
pathOrig.clear ();
@@ -221,6 +226,7 @@ void CSLObj::Load ()
221
226
return ;
222
227
223
228
// If needed it is now the time to copy the .obj file
229
+ DetermineWhichObjToLoad ();
224
230
if (!TriggerCopyAndReplace ())
225
231
return ;
226
232
@@ -808,9 +814,6 @@ void AcTxtLine_OBJ8 (CSLModel& csl,
808
814
if (tokens.size () >= 6 )
809
815
obj.text_lit = CSLModelsConvPackagePath (tokens[5 ], lnNr, true );
810
816
} // TEXTURE available
811
-
812
- // Determine which file to load and if we need a copied .obj file
813
- obj.DetermineWhichObjToLoad ();
814
817
} // Package name valid
815
818
} // at least 3 params
816
819
else
0 commit comments