Commit 0027986c authored by Michael Pyne's avatar Michael Pyne
Browse files

dynamicplaylist: Ensure subclasses handle virtual calls in dtor.

LGTM points out that DynamicPlaylist's destructor calls a function which
indirectly leads to a virtual call (updateItems) in a potential subclass
(SearchPlaylist). By C++ rules, SearchPlaylist has ceased to be a
SearchPlaylist by the time DynamicPlaylist::~DynamicPlaylist() begins,
so the virtual call would never actually be dispatched to
SearchPlaylist.

Fix by having SearchPlaylist do its own updating on destruction.

(cherry picked from commit 36581b2b)
parent 6282bbb5
......@@ -57,10 +57,8 @@ DynamicPlaylist::DynamicPlaylist(const PlaylistList &playlists,
DynamicPlaylist::~DynamicPlaylist()
{
// The Playlist dtor will later clear items when it runs, we need to make
// sure the list is accurate first while we're still able to
checkUpdateItems();
// Subclasses need to ensure they update items in their own destructor, or
// any other virtual calls they may need to make.
lower();
}
......
......@@ -39,6 +39,12 @@ SearchPlaylist::SearchPlaylist(PlaylistCollection *collection,
}
SearchPlaylist::~SearchPlaylist()
{
// DynamicPlaylist needs us to call this while the virtual call still works
updateItems();
}
void SearchPlaylist::setPlaylistSearch(PlaylistSearch* s, bool update)
{
m_search = s;
......
......@@ -29,6 +29,8 @@ public:
bool setupPlaylist = true,
bool synchronizePlaying = false);
virtual ~SearchPlaylist();
PlaylistSearch* playlistSearch() const { return m_search; }
void setPlaylistSearch ( PlaylistSearch* s, bool update = true );
virtual bool searchIsEditable() const override { return true; }
......
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