From ca22cfd31dce75eb59695ee01eb8d10ee2d6a965 Mon Sep 17 00:00:00 2001
From: Jeff Mitchell <jeff@tomahawk-player.org>
Date: Fri, 29 Jun 2012 10:05:55 -0400
Subject: [PATCH] Fix another crash related to debug accessing null pointers

---
 ...tabaseCommand_SetDynamicPlaylistRevision.cpp | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/libtomahawk/database/DatabaseCommand_SetDynamicPlaylistRevision.cpp b/src/libtomahawk/database/DatabaseCommand_SetDynamicPlaylistRevision.cpp
index 7bdc90681..031e434f5 100644
--- a/src/libtomahawk/database/DatabaseCommand_SetDynamicPlaylistRevision.cpp
+++ b/src/libtomahawk/database/DatabaseCommand_SetDynamicPlaylistRevision.cpp
@@ -111,11 +111,18 @@ DatabaseCommand_SetDynamicPlaylistRevision::postCommitHook()
     if( playlist.isNull() ) // if it's neither an auto or station, it must not be auto-loaded, so we MUST have been told about it directly
         rawPl = m_playlist;
 
+    if ( rawPl == 0 )
+    {
+        tLog() <<"Got null playlist with guid:" << playlistguid() << "from source and collection:" << source()->friendlyName() << source()->collection()->name() << "and mode is static?:" << (m_mode == Static);
+        Q_ASSERT( false );
+        return;
+    }
+    
     // workaround a bug in pre-0.1.0 tomahawks. they created dynamic playlists in OnDemand mode *always*, and then set the mode to the real one.
     // now that we separate them, if we get them as one and then get a changed mode, the playlist ends up in the wrong bucket in Collection.
     // so here we fix it if we have to.
     // HACK
-        tDebug() << "Does this need the 0.3->0.1 playlist category hack fix?" << ( rawPl->mode() == Static && source()->collection()->autoPlaylist( playlistguid() ).isNull() )
+    tDebug() << "Does this need the 0.3->0.1 playlist category hack fix?" << ( rawPl->mode() == Static && source()->collection()->autoPlaylist( playlistguid() ).isNull() )
         <<  ( rawPl->mode() == OnDemand && source()->collection()->station( playlistguid() ).isNull() )
                     << rawPl->mode() << source()->collection()->autoPlaylist( playlistguid() ).isNull() << source()->collection()->station( playlistguid() ).isNull();
     if( rawPl->mode() == Static && source()->collection()->autoPlaylist( playlistguid() ).isNull() ) // should be here
@@ -123,13 +130,7 @@ DatabaseCommand_SetDynamicPlaylistRevision::postCommitHook()
     else if ( rawPl->mode() == OnDemand && source()->collection()->station( playlistguid() ).isNull() ) // should be here
         source()->collection()->moveAutoToStation( playlistguid() );
 
-    if ( rawPl == 0 )
-    {
-        tLog() <<"Got null playlist with guid:" << playlistguid() << "from source and collection:" << source()->friendlyName() << source()->collection()->name() << "and mode is static?:" << (m_mode == Static);
-        Q_ASSERT( false );
-        return;
-    }
-    if ( !m_controlsV.isEmpty() && m_controls.isEmpty() )
+  if ( !m_controlsV.isEmpty() && m_controls.isEmpty() )
     {
         QList<QVariantMap> controlMap;
         foreach( const QVariant& v, m_controlsV )