Commit bdc76f4b authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen
Browse files

AlbumTrack: Break circular ownership

Since we're caching some entities, we ended up with a media containing
an album track that contains an album that contains the original media,
thus leading none of those shared pointers to be released
parent a40a4c6b
......@@ -150,9 +150,11 @@ unsigned int AlbumTrack::discNumber() const
std::shared_ptr<IAlbum> AlbumTrack::album()
{
if ( m_album == nullptr && m_albumId != 0 )
auto album = m_album.lock();
if ( album == nullptr && m_albumId != 0 )
{
m_album = Album::fetch( m_dbConnection, m_albumId );
album = Album::fetch( m_dbConnection, m_albumId );
m_album = album;
}
return m_album;
return album;
}
......@@ -76,7 +76,7 @@ class AlbumTrack : public IAlbumTrack, public DatabaseHelpers<AlbumTrack, policy
unsigned int m_releaseYear;
unsigned int m_discNumber;
std::shared_ptr<Album> m_album;
std::weak_ptr<Album> m_album;
friend struct policy::AlbumTrackTable;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment