Packages: fix circular refernece bug

Packages had a strong back-pointer to their catalog, creating a circular
reference loop. Break this so catalogs & packages are freed on exit.
This commit is contained in:
Automatic Release Builder 2020-09-30 15:16:41 +01:00
parent dab015742a
commit bfa411e9b7
2 changed files with 8 additions and 4 deletions

View File

@ -34,7 +34,7 @@ namespace simgear {
namespace pkg {
Package::Package(const SGPropertyNode* aProps, CatalogRef aCatalog) :
m_catalog(aCatalog)
m_catalog(aCatalog.get())
{
initWithProps(aProps);
}
@ -235,6 +235,11 @@ std::string Package::id() const
return m_id;
}
CatalogRef Package::catalog() const
{
return {m_catalog};
}
std::string Package::qualifiedId() const
{
return m_catalog->id() + "." + id();

View File

@ -130,8 +130,7 @@ public:
size_t fileSizeBytes() const;
CatalogRef catalog() const
{ return m_catalog; }
CatalogRef catalog() const;
bool matches(const SGPropertyNode* aFilter) const;
@ -236,7 +235,7 @@ private:
SGPropertyNode_ptr m_props;
std::string m_id;
string_set m_tags;
CatalogRef m_catalog;
Catalog* m_catalog = nullptr; // non-owning ref, explicitly
string_list m_variants;
mutable function_list<InstallCallback> _install_cb;