]> git.sesse.net Git - vlc/commitdiff
Do not use playlist_*AddInput() when the playlist has already been destroyed and...
authorRafaël Carré <funman@videolan.org>
Tue, 11 Mar 2008 18:05:17 +0000 (19:05 +0100)
committerRafaël Carré <funman@videolan.org>
Tue, 11 Mar 2008 18:45:27 +0000 (19:45 +0100)
21 files changed:
modules/access/cdda.c
modules/access/directory.c
modules/control/http/macro.c
modules/control/http/rpn.c
modules/control/rc.c
modules/demux/mp4/mp4.c
modules/gui/macosx/applescript.m
modules/gui/macosx/playlist.m
modules/gui/macosx/wizard.m
modules/gui/qt4/dialogs/open.cpp
modules/gui/qt4/dialogs_provider.cpp
modules/gui/wxwidgets/dialogs/open.cpp
modules/gui/wxwidgets/dialogs/playlist.cpp
modules/gui/wxwidgets/dialogs/wizard.cpp
modules/misc/lua/vlc.c
modules/services_discovery/upnp_cc.cpp
modules/services_discovery/upnp_intel.cpp
src/playlist/engine.c
src/playlist/item.c
src/playlist/loadsave.c
src/playlist/services_discovery.c

index 68a6c873eb4aa6227ba8221063ea25cd93112542..fa982b610341914332af2eb9bff871d3d414f102 100644 (file)
@@ -490,12 +490,15 @@ static int GetTracks( access_t *p_access,
             }
         }
 #endif
-        playlist_BothAddInput( p_playlist, p_input_item, p_item_in_category,
+        int i_ret = playlist_BothAddInput( p_playlist, p_input_item,
+                               p_item_in_category,
                                PLAYLIST_APPEND, PLAYLIST_END, NULL, NULL,
                                VLC_FALSE );
         vlc_gc_decref( p_input_item );
         free( psz_uri ); free( psz_opt ); free( psz_name );
         free( psz_first ); free( psz_last );
+        if( i_ret != VLC_SUCCESS )
+            return VLC_EGENERIC;
     }
     return VLC_SUCCESS;
 }
index 7218bfd293f53531356e24983497df955d862e91..f49a66f57146c8cccd97b8d8a8bd015b46ebe7f8 100644 (file)
@@ -530,13 +530,15 @@ static int ReadDir( playlist_t *p_playlist, const char *psz_name,
                 {
                     if( p_current_input )
                         input_ItemCopyOptions( p_current_input, p_input );
-                    playlist_BothAddInput( p_playlist, p_input,
+                    int i_ret = playlist_BothAddInput( p_playlist, p_input,
                                            p_parent_category,
                                            PLAYLIST_APPEND|PLAYLIST_PREPARSE|
                                            PLAYLIST_NO_REBUILD,
                                            PLAYLIST_END, NULL, NULL,
                                            VLC_FALSE );
                     vlc_gc_decref( p_input );
+                    if( i_ret != VLC_SUCCESS )
+                        return VLC_EGENERIC;
                 }
             }
         }
index acf8ab6f5753f968ead4107ce132efeb55360ebd..95fcf0352e2b288f22d639ccd2bbd18b334a1a25 100644 (file)
@@ -345,11 +345,15 @@ static void MacroDo( httpd_file_sys_t *p_args,
                     }
                     else
                     {
-                        playlist_AddInput( p_sys->p_playlist, p_input,
+                        int i_ret = playlist_AddInput( p_sys->p_playlist,
+                                     p_input,
                                      PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE,
                                      VLC_FALSE);
                         vlc_gc_decref( p_input );
-                        msg_Dbg( p_intf, "requested mrl add: %s", mrl );
+                        if( i_ret == VLC_SUCCESS )
+                            msg_Dbg( p_intf, "requested mrl add: %s", mrl );
+                        else
+                            msg_Warn( p_intf, "adding mrl %s failed", mrl );
                     }
                     free( psz_uri );
 
index ff1bc03b169c94bc9196f09598c8b4e215139bc9..c3644150c55c94cc0734e310f2ff087529f01fa5 100644 (file)
@@ -848,7 +848,10 @@ void E_(EvaluateRPN)( intf_thread_t *p_intf, mvar_t  *vars,
                                    PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE,
                                    VLC_FALSE);
                 vlc_gc_decref( p_input );
-                msg_Dbg( p_intf, "requested mrl add: %s", mrl );
+                if( i_ret == VLC_SUCCESS )
+                    msg_Dbg( p_intf, "requested mrl add: %s", mrl );
+                else
+                    msg_Warn( p_intf, "adding mrl %s failed", mrl );
             }
             free( psz_uri );
             E_(SSPushN)( st, i_ret );
index 94f70cb3cbf31664210ca25ad4f3597158821fef..8e544c047aec3d0c89a6d4c7b9020544e786a29c 100644 (file)
@@ -1423,9 +1423,12 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
         if( p_item )
         {
             msg_rc( "Trying to add %s to playlist.", newval.psz_string );
-            playlist_AddInput( p_playlist, p_item,
+            if( playlist_AddInput( p_playlist, p_item,
                      PLAYLIST_GO|PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE,
-                     VLC_FALSE );
+                     VLC_FALSE ) != VLC_SUCCESS );
+            {
+                return VLC_EGENERIC;
+            }
         }
     }
     else if( !strcmp( psz_cmd, "enqueue" ) &&
@@ -1436,9 +1439,12 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
         if( p_item )
         {
             msg_rc( "trying to enqueue %s to playlist", newval.psz_string );
-            playlist_AddInput( p_playlist, p_item,
+            if( playlist_AddInput( p_playlist, p_item,
                                PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE,
-                               VLC_FALSE);
+                               VLC_FALSE ) != VLC_SUCCESS )
+            {
+                return VLC_EGENERIC;
+            }
         }
     }
     else if( !strcmp( psz_cmd, "playlist" ) )
@@ -1465,7 +1471,7 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
             msg_rc( STATUS_CHANGE "( audio volume: %d )",
                     config_GetInt( p_intf, "volume" ));
 
-            vlc_mutex_lock( &p_playlist->object_lock );
+            PL_LOCK;
             switch( p_playlist->status.i_status )
             {
                 case PLAYLIST_STOPPED:
@@ -1481,7 +1487,7 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
                     msg_rc( STATUS_CHANGE "( state unknown )" );
                     break;
             }
-            vlc_mutex_unlock( &p_playlist->object_lock );
+            PL_UNLOCK;
         }
     }
 
index 196e9c8c3ed9e07dd4073878e059121d980ddcf9..4ee33e7d5c9af6f9f6889e09f4371ab0e07f231f 100644 (file)
@@ -415,7 +415,7 @@ static int Open( vlc_object_t * p_this )
                         asprintf( &psz_absolute, "%s://%s%s",
                                       p_demux->psz_access, psz_path, psz_ref );
 
-                        if( psz_ref ) free( psz_ref );
+                        free( psz_ref );
                         psz_ref = psz_absolute;
                         free( psz_path );
                     }
@@ -426,6 +426,7 @@ static int Open( vlc_object_t * p_this )
                         p_input = input_ItemNewExt( p_playlist, psz_ref, NULL,
                                             0, NULL, -1 );
                         input_ItemCopyOptions( p_current->p_input, p_input );
+                        /* FIXME: playlist_BothAddInput() can fail */
                         playlist_BothAddInput( p_playlist, p_input,
                                                p_item_in_category,
                                                PLAYLIST_APPEND, PLAYLIST_END,
index 70d657be77a9c08ed1928cf04085110acfc46ee4..f64340e536d273611d556a6be40d953786fa5581 100644 (file)
@@ -57,6 +57,7 @@
                                     [o_urlString fileSystemRepresentation],
                                     [[[NSFileManager defaultManager]
                                     displayNameAtPath: o_urlString] UTF8String] );
+            /* FIXME: playlist_AddInput() can fail */
             playlist_AddInput( p_playlist, p_input, PLAYLIST_INSERT,
                                PLAYLIST_END, VLC_TRUE, VLC_FALSE );
 
index ae095c962a0ca54c86f641e375335d077e093dd8..17ce0f44b298885fa718b8169a58d7d205a6e840 100644 (file)
         }
 
         /* Add the item */
+        /* FIXME: playlist_AddInput() can fail */
         playlist_AddInput( p_playlist, p_input, PLAYLIST_INSERT,
              i_position == -1 ? PLAYLIST_END : i_position + i_item, VLC_TRUE,
          VLC_FALSE );
         }
 
         /* Add the item */
+        /* FIXME: playlist_NodeAddInput() can fail */
        playlist_NodeAddInput( p_playlist, p_input, p_node,
                                       PLAYLIST_INSERT,
                                       i_position == -1 ?
index 8f7a5e978dc1c04688db959d2046e396fe58d274..d31ac1ec590203b9b3475378cb7d07cf3422e987 100644 (file)
@@ -1292,6 +1292,7 @@ static VLCWizard *_o_sharedInstance = nil;
                 @"ttl=%@", [o_userSelections objectForKey:@"ttl"]]
                 UTF8String] );
 
+            /* FIXME: playlist_AddInput() can fail */
             playlist_AddInput( p_playlist, p_input, PLAYLIST_STOP,
                 PLAYLIST_END, VLC_TRUE, VLC_FALSE );
 
index 086099bf10ad718ab871fef309c30cb54af7ee54..db9fa45c872922f4a6c3742096d55c10d5a1a9a6 100644 (file)
@@ -316,18 +316,10 @@ void OpenDialog::finish( bool b_enqueue = false )
             }
 
             /* Switch between enqueuing and starting the item */
-            if( b_start )
-            {
-                playlist_AddInput( THEPL, p_input,
-                                   PLAYLIST_APPEND | PLAYLIST_GO,
-                                   PLAYLIST_END, VLC_TRUE, VLC_FALSE );
-            }
-            else
-            {
-                playlist_AddInput( THEPL, p_input,
-                                   PLAYLIST_APPEND | PLAYLIST_PREPARSE,
-                                   PLAYLIST_END, VLC_TRUE, VLC_FALSE );
-            }
+            /* FIXME: playlist_AddInput() can fail */
+            playlist_AddInput( THEPL, p_input,
+                PLAYLIST_APPEND | ( b_start ? PLAYLIST_GO : PLAYLIST_PREPARSE ),
+                PLAYLIST_END, VLC_TRUE, VLC_FALSE );
         }
     }
     else
index ceb0b629b5382b98b74633479d7733c4ed5b9f1a..2fc319b63e1ab0504e514794e64d5826886513ed 100644 (file)
@@ -351,6 +351,7 @@ static void openDirectory( intf_thread_t *p_intf, bool pl, bool go )
                                         qtu( "directory://" + dir ), NULL,
                                         0, NULL, -1 );
 
+        /* FIXME: playlist_AddInput() can fail */
         playlist_AddInput( THEPL, p_input,
                        go ? ( PLAYLIST_APPEND | PLAYLIST_GO ) : PLAYLIST_APPEND,
                        PLAYLIST_END, pl, VLC_FALSE );
index f85150cac1d05e3d93043977c8afc5d1219b39ae..3b92e19fd212f43cc1e4d3fa15479fa579005b4b 100644 (file)
@@ -1205,18 +1205,10 @@ void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
             }
         }
 
-        if( b_start )
-        {
-            playlist_AddInput( p_playlist, p_input,
-                               PLAYLIST_APPEND | PLAYLIST_GO,
-                               PLAYLIST_END, VLC_TRUE, VLC_FALSE );
-        }
-        else
-        {
-            playlist_AddInput( p_playlist, p_input,
-                                       PLAYLIST_APPEND|PLAYLIST_PREPARSE,
-                                       PLAYLIST_END, VLC_TRUE, VLC_FALSE );
-        }
+        /* FIXME: playlist_AddInput() can fail */
+        playlist_AddInput( p_playlist, p_input,
+               PLAYLIST_APPEND | ( b_start ? PLAYLIST_GO : PLAYLIST_PREPARSE ),
+               PLAYLIST_END, VLC_TRUE, VLC_FALSE );
     }
 
     vlc_object_release( p_playlist );
index d60724da7463dfa17410faa1db79d26604be4e04..bc63d436fd032ffba3d36afaf25ab9ba3d00b7e3 100644 (file)
@@ -1289,9 +1289,11 @@ bool PlaylistFileDropTarget::OnDropFiles( wxCoord x, wxCoord y,
         char *psz_utf8 = wxDnDFromLocale( filenames[i] );
         input_item_t *p_input = input_ItemNew( p->p_playlist,
                                               psz_utf8, psz_utf8 );
-        playlist_NodeAddInput( p->p_playlist, p_input,
-                               p_dest, PLAYLIST_PREPARSE, i_pos, VLC_FALSE );
+        int i_ret = ( playlist_NodeAddInput( p->p_playlist, p_input, p_dest,
+                PLAYLIST_PREPARSE, i_pos, VLC_FALSE ) != VLC_SUCCESS );
         wxDnDLocaleFree( psz_utf8 );
+        if( i_ret != VLC_SUCCESS )
+            return FALSE;
     }
 
     /* FIXME: having this Rebuild() is dirty */
index 8b50ca61f1c77b8ed55831c20b254e793317467a..c41448912c4bdfed4b0b8db01ad01d0e48cd7c72 100644 (file)
@@ -1632,6 +1632,7 @@ void WizardDialog::Run()
             snprintf( psz_ttl, 20, "ttl=%i",i_ttl );
             input_ItemAddOption( p_input, psz_ttl );
 
+            /* FIXME: playlist_AddInput() can fail */
             playlist_AddInput( p_playlist, p_input,
                                PLAYLIST_GO, PLAYLIST_END, VLC_TRUE, VLC_FALSE );
             vlc_object_release(p_playlist);
index 7d2a356fecda359e6f51437379fccd780f2dd5f1..ff712c848e8d4271278560ddbab03891bdd9fece 100644 (file)
@@ -748,14 +748,12 @@ int __vlclua_playlist_add_internal( vlc_object_t *p_this, lua_State *L,
                     /* Append item to playlist */
                     if( p_parent ) /* Add to node */
                         input_ItemAddSubItem( p_parent, p_input );
-                    else if( b_play ) /* Play */
+                    else /* Play or Enqueue (preparse) */
+                        /* FIXME: playlist_AddInput() can fail */
                         playlist_AddInput( p_playlist, p_input,
-                                           PLAYLIST_APPEND | PLAYLIST_GO,
-                                           PLAYLIST_END, VLC_TRUE, VLC_FALSE );
-                    else /* Enqueue */
-                        playlist_AddInput( p_playlist, p_input,
-                                           PLAYLIST_APPEND | PLAYLIST_PREPARSE,
-                                           PLAYLIST_END, VLC_TRUE, VLC_FALSE );
+                               PLAYLIST_APPEND | 
+                               ( b_play ? PLAYLIST_GO : PLAYLIST_PREPARSE ),
+                               PLAYLIST_END, VLC_TRUE, VLC_FALSE );
                     i_count ++; /* increment counter */
                     vlc_gc_decref( p_input );
                     while( i_options > 0 )
index 9ae89708093d681c3fb13dab63c42a4a11ecfe54..c9f4594192df50d6fb0b5b6c02b7bd3cb61993f7 100644 (file)
@@ -217,6 +217,7 @@ void UPnPHandler::AddContent( playlist_item_t *p_parent, ContentNode *node )
     {
         ItemNode *iNode = (ItemNode *)node;
         input_item_t *p_input = input_ItemNew( p_sd, iNode->getResource(), title );
+        /* FIXME: playlist_AddInput() can fail */
         playlist_BothAddInput( p_playlist, p_input, p_parent,
                                PLAYLIST_APPEND, PLAYLIST_END, NULL, NULL,
                                VLC_FALSE );
index 3f7a40f003b6d381fc9895b8cd33cbb3a61d21e6..9fe2401c4a1dacb1e5bfba1feb005b171671bb3f 100644 (file)
@@ -871,6 +871,7 @@ void MediaServer::_buildPlaylist( Container* parent )
                                                item->getResource(),
                                                item->getTitle() );
         int i_cat;
+        /* FIXME: playlist_AddInput() can fail */
         playlist_BothAddInput( p_playlist, p_input, parentNode,
                                PLAYLIST_APPEND, PLAYLIST_END, &i_cat, NULL,
                                VLC_FALSE );
index e3af6b8f9c4dfa131bfadbfbb4ac8707b876b40e..7452bbf24d3b6b4e5d117d42e95ddb6ba7ef4c2f 100644 (file)
@@ -500,20 +500,19 @@ void playlist_PreparseLoop( playlist_preparse_t *p_obj )
 
     while( !p_playlist->b_die )
     {
-        vlc_mutex_lock( &p_obj->object_lock );
+        vlc_object_lock( p_obj );
         while( p_obj->i_waiting == 0 )
         {
-            vlc_cond_wait( &p_obj->object_wait, &p_obj->object_lock );
-            if( p_playlist->b_die )
+            if( vlc_object_wait( p_obj ) || p_playlist->b_die )
             {
-                vlc_mutex_unlock( &p_obj->object_lock );
+                vlc_object_unlock( p_obj );
                 return;
             }
         }
 
         p_current = p_obj->pp_waiting[0];
         REMOVE_ELEM( p_obj->pp_waiting, p_obj->i_waiting, 0 );
-        vlc_mutex_unlock( &p_obj->object_lock );
+        vlc_object_unlock( p_obj );
 
         PL_LOCK;
         if( p_current )
@@ -548,12 +547,12 @@ void playlist_PreparseLoop( playlist_preparse_t *p_obj )
                 PL_DEBUG( "need to fetch meta for %s", p_current->psz_name );
                 p.p_item = p_current;
                 p.b_fetch_art = VLC_FALSE;
-                vlc_mutex_lock( &p_playlist->p_fetcher->object_lock );
+                vlc_object_lock( p_playlist->p_fetcher );
                 INSERT_ELEM( p_playlist->p_fetcher->p_waiting,
                              p_playlist->p_fetcher->i_waiting,
                              p_playlist->p_fetcher->i_waiting, p);
-                vlc_cond_signal( &p_playlist->p_fetcher->object_wait );
-                vlc_mutex_unlock( &p_playlist->p_fetcher->object_lock );
+                vlc_object_signal_unlocked( p_playlist->p_fetcher );
+                vlc_object_unlock( p_playlist->p_fetcher );
             }
             /* We already have all needed meta, but we need art right now */
             else if( p_playlist->p_fetcher->i_art_policy == ALBUM_ART_ALL &&
@@ -563,12 +562,12 @@ void playlist_PreparseLoop( playlist_preparse_t *p_obj )
                 PL_DEBUG("meta ok for %s, need to fetch art", psz_name );
                 p.p_item = p_current;
                 p.b_fetch_art = VLC_TRUE;
-                vlc_mutex_lock( &p_playlist->p_fetcher->object_lock );
+                vlc_object_lock( p_playlist->p_fetcher );
                 INSERT_ELEM( p_playlist->p_fetcher->p_waiting,
                              p_playlist->p_fetcher->i_waiting,
                              p_playlist->p_fetcher->i_waiting, p);
-                vlc_cond_signal( &p_playlist->p_fetcher->object_wait );
-                vlc_mutex_unlock( &p_playlist->p_fetcher->object_lock );
+                vlc_object_signal_unlocked( p_playlist->p_fetcher );
+                vlc_object_unlock( p_playlist->p_fetcher );
             }
             else
             {
@@ -583,10 +582,10 @@ void playlist_PreparseLoop( playlist_preparse_t *p_obj )
         else
             PL_UNLOCK;
 
-        vlc_mutex_lock( &p_obj->object_lock );
+        vlc_object_lock( p_obj );
         i_activity = var_GetInteger( p_playlist, "activity" );
         if( i_activity < 0 ) i_activity = 0;
-        vlc_mutex_unlock( &p_obj->object_lock );
+        vlc_object_unlock( p_obj );
         /* Sleep at least 1ms */
         msleep( (i_activity+1) * 1000 );
     }
index bfd190b288dcccfd714d081006827f7f0b66899d..1d723fbeb6fc005f4fdd494c3884e80a85401eae 100644 (file)
@@ -90,11 +90,12 @@ static void input_item_subitem_added( const vlc_event_t * p_event,
             p_item_in_category->p_input->i_type = ITEM_TYPE_PLAYLIST;
         }
 
-        playlist_BothAddInput( p_playlist, p_child, p_item_in_category,
+        int i_ret = playlist_BothAddInput( p_playlist, p_child,
+                p_item_in_category,
                 PLAYLIST_APPEND | PLAYLIST_SPREPARSE , PLAYLIST_END,
                 NULL, NULL,  VLC_TRUE );
 
-        if( b_play )
+        if( i_ret == VLC_SUCCESS && b_play )
         {
             playlist_Control( p_playlist, PLAYLIST_VIEWPLAY,
                           VLC_TRUE, p_item_in_category, NULL );
@@ -368,14 +369,14 @@ int playlist_AddExt( playlist_t *p_playlist, const char * psz_uri,
  *        regardless of its size
  * \param b_playlist TRUE for playlist, FALSE for media library
  * \param b_locked TRUE if the playlist is locked
- * \return VLC_SUCCESS or VLC_ENOMEM
+ * \return VLC_SUCCESS or VLC_ENOMEM or VLC_EGENERIC
 */
 int playlist_AddInput( playlist_t* p_playlist, input_item_t *p_input,
                        int i_mode, int i_pos, vlc_bool_t b_playlist,
                        vlc_bool_t b_locked )
 {
     playlist_item_t *p_item_cat, *p_item_one;
-
+    if( p_playlist->b_die ) return VLC_EGENERIC;
     if( !p_playlist->b_doing_ml )
         PL_DEBUG( "adding item `%s' ( %s )", p_input->psz_name,
                                              p_input->psz_uri );
@@ -417,7 +418,7 @@ int playlist_AddInput( playlist_t* p_playlist, input_item_t *p_input,
  * \param i_cat id of the items category
  * \param i_one id of the item onelevel category
  * \param b_locked TRUE if the playlist is locked
- * \return VLC_SUCCESS or VLC_ENOMEM
+ * \return VLC_SUCCESS if success, VLC_EGENERIC if fail, VLC_ENOMEM if OOM
  */
 int playlist_BothAddInput( playlist_t *p_playlist,
                            input_item_t *p_input,
@@ -428,6 +429,7 @@ int playlist_BothAddInput( playlist_t *p_playlist,
     playlist_item_t *p_item_cat, *p_item_one, *p_up;
     int i_top;
     assert( p_input );
+    if( p_playlist->b_die ) return VLC_EGENERIC;
     if( !b_locked ) PL_LOCK;
 
     /* Add to category */
@@ -488,6 +490,8 @@ playlist_item_t * playlist_NodeAddInput( playlist_t *p_playlist,
     assert( p_input );
     assert( p_parent && p_parent->i_children != -1 );
 
+    if( p_playlist->b_die )
+        return NULL;
     if( !b_locked ) PL_LOCK;
 
     p_item = playlist_ItemNewFromInput( p_playlist, p_input );
index 4f6c0ccfd0951b5f25a410ff31037fc2e306b8ad..b50c76dcdfedc9ae91d9d94c3c1ad63f0957781c 100644 (file)
@@ -101,6 +101,8 @@ static void input_item_subitem_added( const vlc_event_t * p_event,
     playlist_t *p_playlist = user_data;
     input_item_t *p_item = p_event->u.input_item_subitem_added.p_new_child;
 
+    /* playlist_AddInput() can fail, but we have no way to report that ..
+     * Any way when it has failed, either the playlist is dying, either OOM */
     playlist_AddInput( p_playlist, p_item, PLAYLIST_APPEND, PLAYLIST_END,
             VLC_FALSE, VLC_FALSE );
 }
index 3c892eb9bcb8705788bb41d47dc7927e4ef45d70..cf6777fb6f07b5d4787f9d1cc3102196774a9142 100644 (file)
@@ -234,8 +234,11 @@ static void playlist_sd_item_added( const vlc_event_t * p_event, void * user_dat
 
     p_new_item = playlist_NodeAddInput( p_parent->p_playlist, p_input, p_parent,
                                         PLAYLIST_APPEND, PLAYLIST_END, VLC_FALSE );
-    p_new_item->i_flags &= ~PLAYLIST_SKIP_FLAG;
-    p_new_item->i_flags &= ~PLAYLIST_SAVE_FLAG;
+    if( p_new_item )
+    {
+        p_new_item->i_flags &= ~PLAYLIST_SKIP_FLAG;
+        p_new_item->i_flags &= ~PLAYLIST_SAVE_FLAG;
+    }
 }
 
  /* A new item has been removed from a certain sd */