Commit b93e8cf4 authored by Michael Pyne's avatar Michael Pyne
Browse files

search: Fix crash when clicking search playlist after startup.

Search playlists that are loaded with JuK on startup (i.e. because they
were saved from a previous JuK invocation) cause a crash as soon as you
click on the playlist after the recent merge request !18 (which
refactors the search-handling code).

The direct cause is that we were passing a pointer to a stack-allocated
object (in the operator>> for SearchPlaylist), which caused a dangling
pointer once the flow of execution left the stack frame. I did not catch
this during the code review, but found a second instance of this in
PlaylistCollection which I've also fixed.
parent 11cd23fa
Pipeline #15067 passed with stage
in 12 minutes and 11 seconds
......@@ -241,12 +241,12 @@ void PlaylistCollection::showMore(const QString &artist, const QString &album)
components.append(c);
}
PlaylistSearch search(playlists, components, PlaylistSearch::MatchAll);
auto search = new PlaylistSearch(playlists, components, PlaylistSearch::MatchAll, object());
if(m_showMorePlaylist)
m_showMorePlaylist->setPlaylistSearch(&search);
m_showMorePlaylist->setPlaylistSearch(search);
else
m_showMorePlaylist = new SearchPlaylist(this, search, i18n("Now Playing"), false, true);
m_showMorePlaylist = new SearchPlaylist(this, *search, i18n("Now Playing"), false, true);
// The call to raise() below will end up clearing m_belowShowMorePlaylist,
// so cache the value we want it to have now.
......
......@@ -82,16 +82,16 @@ QDataStream &operator<<(QDataStream &s, const SearchPlaylist &p)
QDataStream &operator>>(QDataStream &s, SearchPlaylist &p)
{
QString name;
PlaylistSearch search;
auto search = new PlaylistSearch(&p);
s >> name
>> search;
>> *search;
if(name.isEmpty())
throw BICStreamException();
p.setName(name);
p.setPlaylistSearch(&search, false);
p.setPlaylistSearch(search, false);
return s;
}
......
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