capuchin r55 - trunk/src/libcapuchin



Author: sebp
Date: Fri Mar  7 19:22:41 2008
New Revision: 55
URL: http://svn.gnome.org/viewvc/capuchin?rev=55&view=rev

Log:
Disconnect DownloadManager signals when disposing object. Object will be disposed on close. However, AppObjectManager should count refs for each object and dispose it when no one needs the object anymore.

Modified:
   trunk/src/libcapuchin/AppObject.cs

Modified: trunk/src/libcapuchin/AppObject.cs
==============================================================================
--- trunk/src/libcapuchin/AppObject.cs	(original)
+++ trunk/src/libcapuchin/AppObject.cs	Fri Mar  7 19:22:41 2008
@@ -50,7 +50,6 @@
             this.LocalRepo = Path.Combine(Globals.Instance.LOCAL_CACHE_DIR, Path.GetFileName(repository_url));
             // Used to map DownloadId to PluginID
             this.DownloadToPluginId = new Dictionary<int, string>();
-            Console.WriteLine("NEW DICT");
             
             // Forward DownloadStatus event
             Globals.DLM.DownloadStatus += new DownloadManagerStatusHandler(
@@ -70,6 +69,14 @@
         {
             if (!this.disposed)
             {
+                // Forward DownloadStatus event
+                Globals.DLM.DownloadStatus -= new DownloadManagerStatusHandler(
+                        this.OnDownloadStatus
+                );
+                Globals.DLM.DownloadFinished -= new DownloadManagerFinishedHandler(
+                    this.OnDownloadFinished
+                );                
+                
                 this.RepoItems = null;
                 this.disposed = true;
                 GC.SuppressFinalize(this);
@@ -247,6 +254,7 @@
         public void Close()
         {
             Log.Info("Closing object for {0}", this.ApplicationName);
+            this.Dispose();
             this.OnClosed();
         }
         
@@ -357,6 +365,9 @@
             
         private void OnDownloadStatus (int dlid, double progress, int speed)
         {
+            if (!this.DownloadToPluginId.ContainsKey(dlid))
+                throw new ArgumentException ("Could not find download with id "+dlid);            
+            
             if (dlid == this.repo_dlid)
             {
                 this.OnStatus (ActionType.UpdatingRepo, "", progress, speed);
@@ -367,6 +378,9 @@
         
         private void OnDownloadFinished (int dlid)
         {
+            if (!this.DownloadToPluginId.ContainsKey(dlid))
+                throw new ArgumentException ("Could not find download with id "+dlid);            
+            
             if (dlid == this.repo_dlid) {
                 this.LoadRepository();
                 return;



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