Skip to content

Commit

Permalink
Playlist : fix crash if legacy code fails to load
Browse files Browse the repository at this point in the history
fixes #613

if Playlist::load(...) triggers legacy code when trying to load a playlist,
it creates a temporary Playlist that is destroyed on failure,
thus sets __instance = 0.
In that case the previous __instance must be set back.
  • Loading branch information
jeremyz committed Jul 18, 2018
1 parent bc57598 commit 33002d3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/core/src/basics/playlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Playlist* Playlist::load_file( const QString& pl_path, bool useRelativePaths )
Playlist* pl = new Playlist();
Playlist* ret = Legacy::load_playlist( pl, pl_path );
if ( ret == 0 ) {
delete pl;
delete pl; // __instance = 0;
return 0;
}
WARNINGLOG( QString( "update playlist %1" ).arg( pl_path ) );
Expand Down Expand Up @@ -159,11 +159,15 @@ void Playlist::save_to( XMLNode* node, bool useRelativePaths )

Playlist* Playlist::load( const QString& filename, bool useRelativePaths )
{
// load_file might set __instance = 0;
Playlist* prev = __instance;
Playlist* playlist = Playlist::load_file( filename, useRelativePaths );

if ( playlist != 0 ) {
delete __instance;
delete prev;
__instance = playlist;
} else {
__instance = prev;
}

return playlist;
Expand Down

0 comments on commit 33002d3

Please sign in to comment.