]> git.sesse.net Git - vlc/commitdiff
Better fix for wx deadlock with preparse
authorClément Stenac <zorglub@videolan.org>
Tue, 14 Dec 2004 17:42:42 +0000 (17:42 +0000)
committerClément Stenac <zorglub@videolan.org>
Tue, 14 Dec 2004 17:42:42 +0000 (17:42 +0000)
A few fixes

include/vlc_playlist.h
modules/access/directory.c
modules/gui/wxwindows/playlist.cpp
modules/gui/wxwindows/wxwindows.h
src/input/input.c
src/playlist/item-ext.c
src/playlist/playlist.c
src/playlist/view.c

index 4129b16e775e35ecb53bfe164fac2ec4ff3f82ac..20ca0f4fc139cb01e815ae0b763feb2aeb954831 100644 (file)
@@ -290,7 +290,6 @@ VLC_EXPORT( playlist_item_t *, playlist_ChildSearchName, (playlist_item_t*, cons
 VLC_EXPORT( int, playlist_NodeDelete, ( playlist_t *, playlist_item_t *, vlc_bool_t ) );
 VLC_EXPORT( int, playlist_NodeEmpty, ( playlist_t *, playlist_item_t *, vlc_bool_t ) );
 
-
 /* Tree walking */
 playlist_item_t *playlist_FindNextFromParent( playlist_t *p_playlist,
                 int i_view,
@@ -395,6 +394,8 @@ static inline vlc_bool_t playlist_IsEmpty( playlist_t * p_playlist )
     return( b_empty );
 }
 
+
+
 /**
  * @}
  */
index bd34e74e12c810c7000e070a9db8d259668c9683..24de523d6b398d516af6f76f5bdc5ce23592b356 100644 (file)
@@ -401,7 +401,7 @@ static int ReadDir( playlist_t *p_playlist,
     /* Change the item to a node */
     if( p_parent->i_children == -1 )
     {
-        playlist_ItemToNode( p_playlist,p_parent );
+        playlist_LockItemToNode( p_playlist,p_parent );
     }
 
     /* get the first directory entry */
index 87f02327a9029bc0aeab2869bac8590ecdc5e41c..d114da8addef07fb7fb727f19a651250022d9440 100644 (file)
@@ -60,7 +60,6 @@ static int ItemAppended( vlc_object_t *p_this, const char *psz_variable,
 static int ItemDeleted( vlc_object_t *p_this, const char *psz_variable,
                       vlc_value_t oval, vlc_value_t nval, void *param );
 
-
 /*****************************************************************************
  * Event Table.
  *****************************************************************************/
@@ -405,6 +404,7 @@ Playlist::~Playlist()
     var_DelCallback( p_playlist, "item-change", ItemChanged, this );
     var_DelCallback( p_playlist, "playlist-current", PlaylistNext, this );
     var_DelCallback( p_playlist, "intf-change", PlaylistChanged, this );
+    var_DelCallback( p_playlist, "item-append", ItemAppended, this );
     var_DelCallback( p_playlist, "item-deleted", ItemDeleted, this );
     vlc_object_release( p_playlist );
 }
@@ -1476,13 +1476,17 @@ void Playlist::OnPopupPreparse( wxMenuEvent& event )
     {
         return;
     }
+    Preparse( p_playlist );
+    vlc_object_release( p_playlist );
+}
+
+void Playlist::Preparse( playlist_t *p_playlist )
+{
     if( p_popup_item != NULL )
     {
         if( p_popup_item->i_children == -1 )
         {
-            wxMutexGuiLeave();
             playlist_PreparseEnqueue( p_playlist, &p_popup_item->input );
-            wxMutexGuiEnter();
         }
         else
         {
@@ -1494,11 +1498,10 @@ void Playlist::OnPopupPreparse( wxMenuEvent& event )
                 i_popup_item = FindItem( treectrl->GetRootItem(),
                                          p_parent->pp_children[i] );
                 p_popup_item = p_parent->pp_children[i];
-                OnPopupPreparse( dummy );
+                Preparse( p_playlist );
             }
         }
     }
-    vlc_object_release( p_playlist );
 }
 
 void Playlist::OnPopupDel( wxMenuEvent& event )
index 63c1832ad5c14fe3b7d884310e5a4bece0c64be9..051bd14e61442cfd0635fb62f6a5a289ab6ba6cb 100644 (file)
@@ -855,6 +855,8 @@ private:
     void OnPopupInfo( wxMenuEvent& event );
     void Rebuild();
 
+    void Preparse( playlist_t *p_playlist );
+
     /* Update */
     void UpdateNode( playlist_t *, playlist_item_t*, wxTreeItemId );
     void UpdateNodeChildren( playlist_t *, playlist_item_t*, wxTreeItemId );
index 401eb46712e0bf8254fe3538d0273a601241eaa2..e2473f50fbf85b74594d985ba94ffd4fd3712f73 100644 (file)
@@ -304,6 +304,7 @@ int __input_Preparse( vlc_object_t *p_parent, input_item_t *p_item )
 
     /* Create Object Variables for private use only */
     input_ConfigVarInit( p_input );
+    input_ControlVarInit( p_input );
 
     p_input->input.i_cr_average = var_GetInteger( p_input, "cr-average" );
 
index 2a673c8d87cf4a9b91e315564f8ddf92c85baa15..270659e9d14716b481ac255ccfc92e4521868002 100644 (file)
@@ -622,6 +622,11 @@ int playlist_Replace( playlist_t *p_playlist, playlist_item_t *p_olditem,
  * \return returns VLC_SUCCESS or an error
  */
 int playlist_Delete( playlist_t * p_playlist, int i_id )
+{
+    return playlist_DeleteInternal( p_playlist, i_id );
+}
+int playlist_DeleteInternal( playlist_t * p_playlist, int i_id,
+                             vlc_bool_t b_force )
 {
     vlc_value_t     val;
     int             i;
index 6ea91393c380234e92ee0f769649452f5339313e..ba9cf7af359f1701b8f1c05c3ddbb5dee1c461f1 100644 (file)
@@ -701,10 +701,13 @@ static void RunPreparse ( playlist_preparse_t *p_obj )
 
         if( p_obj->i_waiting > 0 )
         {
-            input_Preparse( p_playlist, p_obj->pp_waiting[0] );
-            var_SetInteger( p_playlist, "item-change",
-                            p_obj->pp_waiting[0]->i_id );
+            input_item_t *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 );
+            input_Preparse( p_playlist, p_current );
+            var_SetInteger( p_playlist, "item-change", p_current->i_id );
+            vlc_mutex_lock( &p_obj->object_lock );
+            fprintf(stderr, "END\n");
         }
         b_sleep = ( p_obj->i_waiting == 0 );
 
index c7e447451aed931bfdcf311afd27827f530bceab..9d85dc756c198330af759099e7aebf7d96f6d42d 100644 (file)
@@ -54,6 +54,11 @@ playlist_item_t *playlist_RecursiveFindPrev( playlist_t *p_playlist,
 void playlist_NodeDump( playlist_t *p_playlist, playlist_item_t *p_item,
                         int i_level );
 
+int playlist_NodeDeleteInternal( playlist_t *p_playlist,
+                                 playlist_item_t *p_root,
+                                 vlc_bool_t b_delete_items, vlc_bool_t b_force );
+
+
 /**********************************************************************
  * Exported View management functions
  **********************************************************************/
@@ -122,6 +127,8 @@ int playlist_ViewInsert( playlist_t *p_playlist, int i_id, char *psz_name )
  */
 int playlist_ViewDelete( playlist_t *p_playlist,playlist_view_t *p_view )
 {
+    playlist_NodeDeleteInternal( p_playlist, p_view->p_root, VLC_TRUE,
+                                 VLC_TRUE );
     REMOVE_ELEM( p_playlist->pp_views, p_playlist->i_views, 0 );
     return VLC_SUCCESS;
 }
@@ -307,6 +314,8 @@ playlist_item_t * playlist_NodeCreate( playlist_t *p_playlist, int i_view,
 /**
  * Remove all the children of a node
  *
+ * This function must be entered with the playlist lock
+ *
  * \param p_playlist the playlist
  * \param p_root the node
  * \param b_delete_items do we have to delete the children items ?
@@ -348,6 +357,14 @@ int playlist_NodeEmpty( playlist_t *p_playlist, playlist_item_t *p_root,
  */
 int playlist_NodeDelete( playlist_t *p_playlist, playlist_item_t *p_root,
                          vlc_bool_t b_delete_items )
+{
+    return playlist_NodeDeleteInternal( p_playlist, p_root,
+                                        b_delete_items, VLC_FALSE );
+}
+
+int playlist_NodeDeleteInternal( playlist_t *p_playlist,
+                                 playlist_item_t *p_root,
+                                 vlc_bool_t b_delete_items, vlc_bool_t b_force )
 {
     int i;
     if( p_root->i_children == -1 )
@@ -370,9 +387,8 @@ int playlist_NodeDelete( playlist_t *p_playlist, playlist_item_t *p_root,
         }
     }
     /* Delete the node */
-    if( p_root->i_flags & PLAYLIST_RO_FLAG )
+    if( p_root->i_flags & PLAYLIST_RO_FLAG && !b_force )
     {
-        msg_Dbg( p_playlist, "unable to remove node, write-protected" );
     }
     else
     {