From 89009c09bedd383fe59e97694eff56b0c2fac79d Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Tue, 6 Mar 2012 18:47:55 -0500 Subject: [PATCH] Add a small guard to Artist::get and Album::get as they are called all over, and might be called after destruction of DB on shutdown --- src/libtomahawk/album.cpp | 3 +++ src/libtomahawk/artist.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/libtomahawk/album.cpp b/src/libtomahawk/album.cpp index f3e426a0a..fbf362427 100644 --- a/src/libtomahawk/album.cpp +++ b/src/libtomahawk/album.cpp @@ -38,6 +38,9 @@ Album::~Album() album_ptr Album::get( const Tomahawk::artist_ptr& artist, const QString& name, bool autoCreate ) { + if ( !Database::instance() || !Database::instance()->impl() ) + return album_ptr(); + int albid = Database::instance()->impl()->albumId( artist->id(), name, autoCreate ); if ( albid < 1 && autoCreate ) return album_ptr(); diff --git a/src/libtomahawk/artist.cpp b/src/libtomahawk/artist.cpp index 18937c4a8..cdefc2505 100644 --- a/src/libtomahawk/artist.cpp +++ b/src/libtomahawk/artist.cpp @@ -38,6 +38,9 @@ Artist::~Artist() artist_ptr Artist::get( const QString& name, bool autoCreate ) { + if ( !Database::instance() || !Database::instance()->impl() ) + return artist_ptr(); + int artid = Database::instance()->impl()->artistId( name, autoCreate ); if ( artid < 1 && autoCreate ) return artist_ptr();