Fix memory leaks in CollectionObject by making ob a weak pointer and removing prev pointer.
Something was cyclic in CollectionObject and we don't traverse backwards anywayspull/4193/head
parent
e831ecf3c2
commit
095bd67e10
|
@ -325,7 +325,7 @@ void BlenderImporter::ParseSubCollection(const Blender::Scene &in, aiNode *root,
|
||||||
// Count number of objects
|
// Count number of objects
|
||||||
for (std::shared_ptr<CollectionObject> cur = std::static_pointer_cast<CollectionObject>(collection->gobject.first); cur; cur = cur->next) {
|
for (std::shared_ptr<CollectionObject> cur = std::static_pointer_cast<CollectionObject>(collection->gobject.first); cur; cur = cur->next) {
|
||||||
if (cur->ob) {
|
if (cur->ob) {
|
||||||
root_objects.push_back(cur->ob.get());
|
root_objects.push_back(cur->ob);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::deque<Collection *> root_children;
|
std::deque<Collection *> root_children;
|
||||||
|
|
|
@ -100,9 +100,18 @@ void Structure::Convert<CollectionObject>(
|
||||||
CollectionObject &dest,
|
CollectionObject &dest,
|
||||||
const FileDatabase &db) const {
|
const FileDatabase &db) const {
|
||||||
|
|
||||||
ReadFieldPtr<ErrorPolicy_Fail>(dest.prev, "*prev", db);
|
|
||||||
ReadFieldPtr<ErrorPolicy_Fail>(dest.next, "*next", db);
|
ReadFieldPtr<ErrorPolicy_Fail>(dest.next, "*next", db);
|
||||||
ReadFieldPtr<ErrorPolicy_Igno>(dest.ob, "*ob", db);
|
{
|
||||||
|
//std::shared_ptr<CollectionObject> prev;
|
||||||
|
//ReadFieldPtr<ErrorPolicy_Fail>(prev, "*prev", db);
|
||||||
|
//dest.prev = prev.get();
|
||||||
|
|
||||||
|
std::shared_ptr<Object> ob;
|
||||||
|
ReadFieldPtr<ErrorPolicy_Igno>(ob, "*ob", db);
|
||||||
|
dest.ob = ob.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
db.reader->IncPtr(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------
|
||||||
|
|
|
@ -107,6 +107,7 @@ namespace Blender {
|
||||||
struct Object;
|
struct Object;
|
||||||
struct MTex;
|
struct MTex;
|
||||||
struct Image;
|
struct Image;
|
||||||
|
struct Collection;
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
@ -147,18 +148,11 @@ struct Group : ElemBase {
|
||||||
std::shared_ptr<GroupObject> gobject;
|
std::shared_ptr<GroupObject> gobject;
|
||||||
};
|
};
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------
|
|
||||||
struct Collection : ElemBase {
|
|
||||||
ID id FAIL;
|
|
||||||
ListBase gobject; // CollectionObject
|
|
||||||
ListBase children; // CollectionChild
|
|
||||||
//ListBase objects; // Objects
|
|
||||||
};
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------
|
||||||
struct CollectionObject : ElemBase {
|
struct CollectionObject : ElemBase {
|
||||||
std::shared_ptr<CollectionObject> next, prev;
|
//CollectionObject* prev;
|
||||||
std::shared_ptr<Object> ob;
|
std::shared_ptr<CollectionObject> next;
|
||||||
|
Object *ob;
|
||||||
};
|
};
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------
|
||||||
|
@ -167,6 +161,13 @@ struct CollectionChild : ElemBase {
|
||||||
std::shared_ptr<Collection> collection;
|
std::shared_ptr<Collection> collection;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------------
|
||||||
|
struct Collection : ElemBase {
|
||||||
|
ID id FAIL;
|
||||||
|
ListBase gobject; // CollectionObject
|
||||||
|
ListBase children; // CollectionChild
|
||||||
|
};
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------
|
||||||
struct World : ElemBase {
|
struct World : ElemBase {
|
||||||
ID id FAIL;
|
ID id FAIL;
|
||||||
|
|
Loading…
Reference in New Issue