Fix playlist memory leak

When the current playlist is changed, PlaylistContainer::SetViewModel is called
to set the new list. This calls PlaylistView::SetItemDelegates, which allocates
several objects that are never freed. Instead, move the call to SetItemDelegates
to PlaylistContainer::SetApplication, which is only called once.
This commit is contained in:
Jim Broadus 2020-07-09 00:10:00 -07:00 committed by John Maguire
parent 3bfaf3ff38
commit c75fa0077e
1 changed files with 2 additions and 1 deletions

View File

@ -123,6 +123,8 @@ void PlaylistContainer::SetApplication(Application* app) {
app_ = app;
SetManager(app_->playlist_manager());
ui_->playlist->SetApplication(app_);
// This should not be called before SetApplication.
view()->SetItemDelegates(manager_->library_backend());
connect(app_, SIGNAL(SaveSettings(QSettings*)), SLOT(Save(QSettings*)));
}
@ -200,7 +202,6 @@ void PlaylistContainer::SetViewModel(Playlist* playlist) {
// Set the view
playlist->IgnoreSorting(true);
view()->setModel(playlist->proxy());
view()->SetItemDelegates(manager_->library_backend());
view()->SetPlaylist(playlist);
view()->selectionModel()->select(manager_->current_selection(),
QItemSelectionModel::ClearAndSelect);