mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
CTypeList: Apply changes from a50a32405d
Use weak_ptr for TypeDescriptor cross-links. Fixed total TypeDescriptor memory leak.
This commit is contained in:
parent
5b76c3f4eb
commit
8f349b5105
@ -62,8 +62,9 @@ std::vector<CTypeList::TypeInfoPtr> CTypeList::castSequence(TypeInfoPtr from, Ty
|
||||
{
|
||||
auto typeNode = q.front();
|
||||
q.pop();
|
||||
for(auto &nodeBase : upcast ? typeNode->parents : typeNode->children)
|
||||
for(auto & weakNode : (upcast ? typeNode->parents : typeNode->children) )
|
||||
{
|
||||
auto nodeBase = weakNode.lock();
|
||||
if(!previous.count(nodeBase))
|
||||
{
|
||||
previous[nodeBase] = typeNode;
|
||||
|
@ -66,11 +66,12 @@ class DLL_LINKAGE CTypeList: public boost::noncopyable
|
||||
//public:
|
||||
struct TypeDescriptor;
|
||||
typedef std::shared_ptr<TypeDescriptor> TypeInfoPtr;
|
||||
typedef std::weak_ptr<TypeDescriptor> WeakTypeInfoPtr;
|
||||
struct TypeDescriptor
|
||||
{
|
||||
ui16 typeID;
|
||||
const char *name;
|
||||
std::vector<TypeInfoPtr> children, parents;
|
||||
std::vector<WeakTypeInfoPtr> children, parents;
|
||||
};
|
||||
typedef boost::shared_mutex TMutex;
|
||||
typedef boost::unique_lock<TMutex> TUniqueLock;
|
||||
|
Loading…
Reference in New Issue
Block a user