Author: ankit
Date: 2007-06-13 16:49:28 -0400 (Wed, 13 Jun 2007)
New Revision: 79504

Modified:
   trunk/monodevelop/Extras/MonoDevelop.Autotools/ChangeLog
   trunk/monodevelop/Extras/MonoDevelop.Autotools/MakefileData.cs
Log:
* MakefileData.cs (PkgManagerTable): New. A global table to keep weak
references to ConfiguredPackagesManager objects.
(UpdateProject): Use the new PkgManagerTable.
(ConfiguredPackagesManager.LastWriteTime): New.


Modified: trunk/monodevelop/Extras/MonoDevelop.Autotools/ChangeLog
===================================================================
--- trunk/monodevelop/Extras/MonoDevelop.Autotools/ChangeLog    2007-06-13 
20:49:16 UTC (rev 79503)
+++ trunk/monodevelop/Extras/MonoDevelop.Autotools/ChangeLog    2007-06-13 
20:49:28 UTC (rev 79504)
@@ -1,3 +1,10 @@
+2007-06-14  Ankit Jain  <[EMAIL PROTECTED]>
+
+       * MakefileData.cs (PkgManagerTable): New. A global table to keep weak
+       references to ConfiguredPackagesManager objects.
+       (UpdateProject): Use the new PkgManagerTable.
+       (ConfiguredPackagesManager.LastWriteTime): New.
+
 2007-06-07  Ankit Jain  <[EMAIL PROTECTED]>
 
        * AutotoolsContext.cs (NormalizeRelativePath): Moved to 
Runtime.FileService .

Modified: trunk/monodevelop/Extras/MonoDevelop.Autotools/MakefileData.cs
===================================================================
--- trunk/monodevelop/Extras/MonoDevelop.Autotools/MakefileData.cs      
2007-06-13 20:49:16 UTC (rev 79503)
+++ trunk/monodevelop/Extras/MonoDevelop.Autotools/MakefileData.cs      
2007-06-13 20:49:28 UTC (rev 79504)
@@ -597,6 +597,19 @@
                        }
                }
 
+               // Global table for keeping weak references to 
ConfiguredPackagesManager objects,
+               // one per configure.in file. A strong reference to the object 
is kept in
+               // every project's ExtendedProperties, this ensures that it 
won't get collected
+               // too early.
+               static Dictionary<string, WeakReference> pkgManagerTable = null;
+               static Dictionary<string, WeakReference> PkgManagerTable {
+                       get {
+                               if (pkgManagerTable == null)
+                                       pkgManagerTable = new 
Dictionary<string, WeakReference> ();
+                               return pkgManagerTable;
+                       }
+               }
+
                //use events.. 
                public void UpdateProject (IProgressMonitor monitor, bool 
promptForRemoval)
                {
@@ -636,8 +649,27 @@
                        encodeValues = null;
 
                        try {
-                               if (IsAutotoolsProject)
-                                       configuredPackages = new 
ConfiguredPackagesManager (Path.Combine (AbsoluteConfigureInPath, 
"configure.in"));
+                               if (IsAutotoolsProject) {
+                                       string path = Path.Combine 
(AbsoluteConfigureInPath, "configure.in");
+                                       configuredPackages = null;
+                                       WeakReference weakref;
+                                       if (PkgManagerTable.TryGetValue (path, 
out weakref)) {
+                                               if (weakref.IsAlive) {
+                                                       configuredPackages = 
(ConfiguredPackagesManager) weakref.Target;
+                                                       FileInfo finfo = new 
FileInfo (path);
+                                                       if (finfo.LastWriteTime 
> configuredPackages.LastWriteTime)
+                                                               // file has 
changed since last time we parsed it!
+                                                               
configuredPackages = null;
+                                               }
+                                       }
+
+                                       // no entry in table or it got 
collected or file has changed
+                                       if (configuredPackages == null) {
+                                               configuredPackages = new 
ConfiguredPackagesManager (path);
+                                               PkgManagerTable [path] = new 
WeakReference (configuredPackages);
+                                               ownerProject.ExtendedProperties 
["MonoDevelop.Autotools.ConfiguredPackagesManager"] = configuredPackages;
+                                       }
+                               }
                        } catch (Exception e) {
                                Console.WriteLine (String.Format (
                                        "Error trying to read configure.in : 
{0} for project {1} : {2} ",
@@ -1557,6 +1589,7 @@
                Dictionary<string, string> varNameAcSubst;
 
                string fullpath;
+               DateTime lastWriteTime;
 
                public ConfiguredPackagesManager (string fullpath)
                {
@@ -1566,6 +1599,8 @@
                                //FIXME: Exception type?
                                throw new ArgumentException 
(GettextCatalog.GetString ("Unable to find configure.in at {0}", fullpath));
 
+                       FileInfo finfo = new FileInfo (fullpath);
+                       lastWriteTime = finfo.LastWriteTime;
                        ReadPackagesList ();
                }
 
@@ -1647,6 +1682,10 @@
                        }
                }
 
+               public DateTime LastWriteTime {
+                       get { return lastWriteTime; }
+               }
+
                static Regex pkgCheckModulesRegex = null;
                static Regex PkgCheckModulesRegex {
                        get {

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to