Skip to content

Commit d4c21ec

Browse files
authored
Merge pull request scp-fs2open#7514 from Goober5000/fix/7513
invalidate UI render instance cache when freeing model instances
2 parents 60203b6 + 96d1988 commit d4c21ec

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

code/model/modelread.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "math/fvi.h"
3232
#include "math/vecmat.h"
3333
#include "model/model.h"
34+
#include "model/modelrender.h"
3435
#include "model/modelreplace.h"
3536
#include "model/modelsinc.h"
3637
#include "parse/parselo.h"
@@ -338,6 +339,10 @@ void model_instance_free_all()
338339
{
339340
size_t i;
340341

342+
// invalidate the UI render instance cache first so it doesn't retain stale references
343+
// into Polygon_model_instances after the loop below
344+
model_clear_cached_ui_render_instances();
345+
341346
// free any outstanding model instances
342347
for ( i = 0; i < Polygon_model_instances.size(); ++i ) {
343348
if ( Polygon_model_instances[i] ) {

0 commit comments

Comments
 (0)