Fix memory leak [skip ci]
parent
082b5ea1f1
commit
87f5136714
|
@ -431,8 +431,7 @@ MeshCombiner::Mesh *MeshGenerator::combinePartMesh(const QString &partIdString,
|
||||||
partCache.previewVertices.clear();
|
partCache.previewVertices.clear();
|
||||||
partCache.isSuccessful = false;
|
partCache.isSuccessful = false;
|
||||||
partCache.joined = (target == PartTarget::Model && !isDisabled);
|
partCache.joined = (target == PartTarget::Model && !isDisabled);
|
||||||
delete partCache.mesh;
|
partCache.releaseMeshes();
|
||||||
partCache.mesh = nullptr;
|
|
||||||
|
|
||||||
struct NodeInfo
|
struct NodeInfo
|
||||||
{
|
{
|
||||||
|
@ -1471,6 +1470,7 @@ void MeshGenerator::generate()
|
||||||
}
|
}
|
||||||
m_cacheContext->partMirrorIdMap.erase(mirrorFrom);
|
m_cacheContext->partMirrorIdMap.erase(mirrorFrom);
|
||||||
}
|
}
|
||||||
|
it->second.releaseMeshes();
|
||||||
it = m_cacheContext->parts.erase(it);
|
it = m_cacheContext->parts.erase(it);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1487,6 +1487,7 @@ void MeshGenerator::generate()
|
||||||
}
|
}
|
||||||
combinationIt++;
|
combinationIt++;
|
||||||
}
|
}
|
||||||
|
it->second.releaseMeshes();
|
||||||
it = m_cacheContext->components.erase(it);
|
it = m_cacheContext->components.erase(it);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,13 @@ class GeneratedPart
|
||||||
public:
|
public:
|
||||||
~GeneratedPart()
|
~GeneratedPart()
|
||||||
{
|
{
|
||||||
delete mesh;
|
releaseMeshes();
|
||||||
};
|
};
|
||||||
|
void releaseMeshes()
|
||||||
|
{
|
||||||
|
delete mesh;
|
||||||
|
mesh = nullptr;
|
||||||
|
}
|
||||||
MeshCombiner::Mesh *mesh = nullptr;
|
MeshCombiner::Mesh *mesh = nullptr;
|
||||||
std::vector<QVector3D> vertices;
|
std::vector<QVector3D> vertices;
|
||||||
std::vector<std::vector<size_t>> faces;
|
std::vector<std::vector<size_t>> faces;
|
||||||
|
@ -63,6 +68,15 @@ public:
|
||||||
class GeneratedCacheContext
|
class GeneratedCacheContext
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
~GeneratedCacheContext()
|
||||||
|
{
|
||||||
|
for (auto &it: cachedCombination)
|
||||||
|
delete it.second;
|
||||||
|
for (auto &it: parts)
|
||||||
|
it.second.releaseMeshes();
|
||||||
|
for (auto &it: components)
|
||||||
|
it.second.releaseMeshes();
|
||||||
|
}
|
||||||
std::map<QString, GeneratedComponent> components;
|
std::map<QString, GeneratedComponent> components;
|
||||||
std::map<QString, GeneratedPart> parts;
|
std::map<QString, GeneratedPart> parts;
|
||||||
std::map<QString, QString> partMirrorIdMap;
|
std::map<QString, QString> partMirrorIdMap;
|
||||||
|
|
Loading…
Reference in New Issue