Commit 36581b2b 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

Fix by having SearchPlaylist do its own updating on destruction.
parent cbfe92c3
Pipeline #55408 passed with stage
in 10 minutes and 49 seconds
......@@ -57,10 +57,8 @@ DynamicPlaylist::DynamicPlaylist(const PlaylistList &playlists,
// 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
// Subclasses need to ensure they update items in their own destructor, or
// any other virtual calls they may need to make.
......@@ -39,6 +39,12 @@ SearchPlaylist::SearchPlaylist(PlaylistCollection *collection,
// DynamicPlaylist needs us to call this while the virtual call still works
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; }
Supports Markdown
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