banshee r4353 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Collection src/Dap/Banshee.Dap/Banshee.Dap src/Libraries/Hyena/Hyena.Collections



Author: gburt
Date: Tue Aug 12 17:37:35 2008
New Revision: 4353
URL: http://svn.gnome.org/viewvc/banshee?rev=4353&view=rev

Log:
2008-08-12  Gabriel Burt  <gabriel burt gmail com>

	* src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs: Catch and log exceptions
	thrown while loading the device's items.

	* src/Core/Banshee.Services/Banshee.Collection/ImportManager.cs: Don't
	create the user job if it's just going to be hidden.  Avoid a NRE if the
	ImportElement already fired the Finished event and the job was destroyed.

	* src/Libraries/Hyena/Hyena.Collections/QueuePipelineElement.cs: Prevent
	NRE by making sure the element is threaded.  This and the above NRE fix
	should fix the bug with mass storage devices not getting loaded (BGO
	#545604).


Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.Services/Banshee.Collection/ImportManager.cs
   trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs
   trunk/banshee/src/Libraries/Hyena/Hyena.Collections/QueuePipelineElement.cs

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection/ImportManager.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection/ImportManager.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection/ImportManager.cs	Tue Aug 12 17:37:35 2008
@@ -153,7 +153,7 @@
         private void CreateUserJob ()
         {
             lock (user_job_mutex) {
-                if (user_job != null) {
+                if (user_job != null || KeepUserJobHidden) {
                     return;
                 }
                 
@@ -200,19 +200,20 @@
         protected void UpdateProgress (string message)
         {
             CreateUserJob ();
-            
-            double new_progress = (double)import_element.ProcessedCount / (double)import_element.TotalCount;
-            double old_progress = user_job.Progress;
-            
-            if (new_progress >= 0.0 && new_progress <= 1.0 && Math.Abs (new_progress - old_progress) > 0.001) {
-                lock (number_format) {
-                    string disp_progress = String.Format (ProgressMessage, 
-                        import_element.ProcessedCount.ToString ("N", number_format), 
-                        import_element.TotalCount.ToString ("N", number_format));
-                    
-                    user_job.Title = disp_progress;
-                    user_job.Status = String.IsNullOrEmpty (message) ? Catalog.GetString ("Scanning...") : message;
-                    user_job.Progress = new_progress;
+            if (user_job != null) {
+                double new_progress = (double)import_element.ProcessedCount / (double)import_element.TotalCount;
+                double old_progress = user_job.Progress;
+                
+                if (new_progress >= 0.0 && new_progress <= 1.0 && Math.Abs (new_progress - old_progress) > 0.001) {
+                    lock (number_format) {
+                        string disp_progress = String.Format (ProgressMessage, 
+                            import_element.ProcessedCount.ToString ("N", number_format), 
+                            import_element.TotalCount.ToString ("N", number_format));
+                        
+                        user_job.Title = disp_progress;
+                        user_job.Status = String.IsNullOrEmpty (message) ? Catalog.GetString ("Scanning...") : message;
+                        user_job.Progress = new_progress;
+                    }
                 }
             }
         }
@@ -221,12 +222,15 @@
         
         private void UpdateScannerProgress ()
         {
-            if (DateTime.Now - last_enqueue_display > TimeSpan.FromMilliseconds (400)) {
-                lock (number_format) {
-                    number_format.NumberDecimalDigits = 0;
-                    user_job.Status = String.Format (Catalog.GetString ("Scanning ({0} files)..."), 
-                        import_element.TotalCount.ToString ("N", number_format));
-                    last_enqueue_display = DateTime.Now;
+            CreateUserJob ();
+            if (user_job != null) {
+                if (DateTime.Now - last_enqueue_display > TimeSpan.FromMilliseconds (400)) {
+                    lock (number_format) {
+                        number_format.NumberDecimalDigits = 0;
+                        user_job.Status = String.Format (Catalog.GetString ("Scanning ({0} files)..."), 
+                            import_element.TotalCount.ToString ("N", number_format));
+                        last_enqueue_display = DateTime.Now;
+                    }
                 }
             }
         }

Modified: trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs	(original)
+++ trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs	Tue Aug 12 17:37:35 2008
@@ -208,11 +208,15 @@
         
         private void ThreadedLoadDeviceContents (object state)
         {
-            PurgeTracks ();
-            SetStatus (String.Format (Catalog.GetString ("Loading {0}"), Name), false);
-            LoadFromDevice ();
-            OnTracksAdded ();
-            HideStatus ();
+            try {
+                PurgeTracks ();
+                SetStatus (String.Format (Catalog.GetString ("Loading {0}"), Name), false);
+                LoadFromDevice ();
+                OnTracksAdded ();
+                HideStatus ();
+            } catch (Exception e) {
+                Log.Exception (e);
+            }
         }
 
         protected virtual void LoadFromDevice ()

Modified: trunk/banshee/src/Libraries/Hyena/Hyena.Collections/QueuePipelineElement.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena/Hyena.Collections/QueuePipelineElement.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena/Hyena.Collections/QueuePipelineElement.cs	Tue Aug 12 17:37:35 2008
@@ -121,6 +121,9 @@
                 
                 lock (this) {
                     processing = false;
+                }
+
+                if (threaded) {
                     thread_wait.Close ();
                     thread_wait = null;
                 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]