diff options
author | Uwe Klotz <uwe_klotz@web.de> | 2016-12-08 23:19:16 +0100 |
---|---|---|
committer | Uwe Klotz <uwe_klotz@web.de> | 2016-12-09 23:45:42 +0100 |
commit | 9eb92d0f3b52316ddd2e34e84c94ca44b58ac3fe (patch) | |
tree | 94feccb1aca633c08c90ff0299173173019cf636 /src/library/banshee | |
parent | 7d2e0fce392413c7a4f4292ccc0dd5e5f45f496f (diff) |
Simplify and safeguard memory management of TreeItem(Model)
Diffstat (limited to 'src/library/banshee')
-rw-r--r-- | src/library/banshee/bansheefeature.cpp | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/library/banshee/bansheefeature.cpp b/src/library/banshee/bansheefeature.cpp index 884c79947c..3973ad7d6d 100644 --- a/src/library/banshee/bansheefeature.cpp +++ b/src/library/banshee/bansheefeature.cpp @@ -91,25 +91,19 @@ void BansheeFeature::activate() { m_isActivated = true; - TreeItem* playlist_root = new TreeItem(this); - - QList<struct BansheeDbConnection::Playlist> list = m_connection.getPlaylists(); - - struct BansheeDbConnection::Playlist playlist; - foreach (playlist, list) { + auto pRootItem = std::make_unique<TreeItem>(this); + QList<BansheeDbConnection::Playlist> playlists = m_connection.getPlaylists(); + for (const BansheeDbConnection::Playlist& playlist: playlists) { qDebug() << playlist.name; // append the playlist to the child model - playlist_root->appendChild( - new TreeItem(this, playlist.name, playlist.playlistId)); + pRootItem->appendChild(playlist.name, playlist.playlistId); } + m_childModel.setRootItem(std::move(pRootItem)); - if (playlist_root) { - m_childModel.setRootItem(playlist_root); - if (m_isActivated) { - activate(); - } - qDebug() << "Banshee library loaded: success"; + if (m_isActivated) { + activate(); } + qDebug() << "Banshee library loaded: success"; //calls a slot in the sidebarmodel such that 'isLoading' is removed from the feature title. m_title = tr("Banshee"); |