[vlc-devel] commit: Fix the update system now we can' t close vlc and stop the download correctly. ( Rémi Duraffort )

git version control git at videolan.org
Wed Jun 25 22:42:57 CEST 2008


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Wed Jun 25 22:38:44 2008 +0200| [3e621f3fd9ed1d3e4488b5078c62ec00cc069124]

Fix the update system now we can't close vlc and stop the download correctly.
Should fixe #1635

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3e621f3fd9ed1d3e4488b5078c62ec00cc069124
---

 src/misc/update.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/misc/update.c b/src/misc/update.c
index 4a19aec..51d6ecb 100644
--- a/src/misc/update.c
+++ b/src/misc/update.c
@@ -1524,9 +1524,12 @@ static void update_DownloadReal( update_download_thread_t *p_udt )
         free( psz_status );
     }
 
-    while( ( i_read = stream_Read( p_stream, p_buffer, 1 << 10 ) ) &&
-                                   !intf_ProgressIsCancelled( p_udt, i_progress ) )
+    vlc_object_lock( p_udt );
+    while( vlc_object_alive( p_udt ) &&
+           ( i_read = stream_Read( p_stream, p_buffer, 1 << 10 ) ) &&
+           !intf_ProgressIsCancelled( p_udt, i_progress ) )
     {
+        vlc_object_unlock( p_udt );
         if( fwrite( p_buffer, i_read, 1, p_file ) < 1 )
         {
             msg_Err( p_udt, "Failed to write into %s", psz_destfile );
@@ -1545,14 +1548,17 @@ static void update_DownloadReal( update_download_thread_t *p_udt )
             free( psz_status );
         }
         free( psz_downloaded );
+        vlc_object_lock( p_udt );
     }
 
     /* Finish the progress bar or delete the file if the user had canceled */
     fclose( p_file );
     p_file = NULL;
 
-    if( !intf_ProgressIsCancelled( p_udt, i_progress ) )
+    if( vlc_object_alive( p_udt ) &&
+        !intf_ProgressIsCancelled( p_udt, i_progress ) )
     {
+        vlc_object_unlock( p_udt );
         if( asprintf( &psz_status, "%s\nDone %s (100.0%%)",
             p_update->release.psz_url, psz_size ) != -1 )
         {
@@ -1562,6 +1568,7 @@ static void update_DownloadReal( update_download_thread_t *p_udt )
     }
     else
     {
+        vlc_object_unlock( p_udt );
         utf8_unlink( psz_destfile );
         goto end;
     }




More information about the vlc-devel mailing list