Delete parents after base objects

* This fixes a potential crash deleting an image view after an image, by
  ensuring a non-owning pointer to the image's resinfo remains valid until after
  the image view is destroyed.
This commit is contained in:
baldurk
2025-09-25 16:17:46 +01:00
parent 39c7dc1027
commit 4df53b41d3
+5 -3
View File
@@ -213,10 +213,9 @@ void ResourceRecord::Delete(ResourceRecordHandler *mgr)
RDCASSERT(ref >= 0);
if(ref <= 0)
{
for(auto it = Parents.begin(); it != Parents.end(); ++it)
(*it)->Delete(mgr);
rdcarray<ResourceRecord *> ParentsToDelete;
Parents.swap(ParentsToDelete);
Parents.clear();
Length = 0;
DataPtr = NULL;
@@ -226,5 +225,8 @@ void ResourceRecord::Delete(ResourceRecordHandler *mgr)
mgr->RemoveResourceRecord(ResID);
mgr->DestroyResourceRecord(this);
for(auto it = ParentsToDelete.begin(); it != ParentsToDelete.end(); ++it)
(*it)->Delete(mgr);
}
}