From 33002d3584094b3c398a9f012ef95e7ae87a86ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 18 Jul 2018 11:54:04 +0200 Subject: [PATCH] Playlist : fix crash if legacy code fails to load 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. --- src/core/src/basics/playlist.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/src/basics/playlist.cpp b/src/core/src/basics/playlist.cpp index e47172b8ef..199bb8d1e5 100644 --- a/src/core/src/basics/playlist.cpp +++ b/src/core/src/basics/playlist.cpp @@ -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 ) ); @@ -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;