[Monodevelop-patches-list] r2143 - in trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor: . Gui

commit-watcher at mono-cvs.ximian.com commit-watcher at mono-cvs.ximian.com
Sun Jan 16 18:27:09 EST 2005


Author: lluis
Date: 2005-01-16 18:27:09 -0500 (Sun, 16 Jan 2005)
New Revision: 2143

Modified:
   trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/ChangeLog
   trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorDisplayBinding.cs
Log:
	* Gui/SourceEditorDisplayBinding.cs: Use a different method for detecting
	that a file change event is the result of a save operation (the current
	doesn't work if the that event is delayed).

2005-01-11  Lluis Sanchez Gual  <lluis at novell.com>



Modified: trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/ChangeLog	2005-01-15 04:41:29 UTC (rev 2142)
+++ trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/ChangeLog	2005-01-16 23:27:09 UTC (rev 2143)
@@ -1,5 +1,11 @@
 2005-01-11  Lluis Sanchez Gual  <lluis at novell.com>
 
+	* Gui/SourceEditorDisplayBinding.cs: Use a different method for detecting
+	that a file change event is the result of a save operation (the current
+	doesn't work if the that event is delayed).
+
+2005-01-11  Lluis Sanchez Gual  <lluis at novell.com>
+
 	* Gui/Dialogs/ExportProjectToHtmlDialog.cs:
 	* InsightWindow/MethodInsightDataProvider.cs:
 	* InsightWindow/InsightWindow.cs:

Modified: trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorDisplayBinding.cs
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorDisplayBinding.cs	2005-01-15 04:41:29 UTC (rev 2142)
+++ trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorDisplayBinding.cs	2005-01-16 23:27:09 UTC (rev 2143)
@@ -100,12 +100,16 @@
 	
 		internal SourceEditor se;
 
+		object fileSaveLock = new object ();
+		DateTime lastSaveTime;
+		
 		void UpdateFSW (object o, EventArgs e)
 		{
 			if (ContentName == null || ContentName.Length == 0)
 				return;
 
 			fsw.EnableRaisingEvents = false;
+			lastSaveTime = File.GetLastWriteTime (ContentName);
 			fsw.Path = Path.GetDirectoryName (ContentName);
 			fsw.Filter = Path.GetFileName (ContentName);
 			fsw.EnableRaisingEvents = true;
@@ -113,8 +117,10 @@
 
 		private void OnFileChanged (object o, FileSystemEventArgs e)
 		{
-			if (isSaving)
-				return;
+			lock (fileSaveLock) {
+				if (lastSaveTime == File.GetLastWriteTime (ContentName))
+					return;
+			}
 			DispatchService dispatcher = (DispatchService)ServiceManager.GetService (typeof (DispatchService));
 			dispatcher.GuiDispatch (new StatefulMessageHandler (realFileChanged), e);
 		}
@@ -239,23 +245,21 @@
 			}
 		}
 		
-		bool isSaving = false;
 		public override void Save (string fileName)
 		{
-			isSaving = true;
-			se.Buffer.Save (fileName);
+			lock (fileSaveLock) {
+				se.Buffer.Save (fileName);
+				lastSaveTime = File.GetLastWriteTime (fileName);
+			}
 			ContentName = fileName;
 			InitializeFormatter ();
-			isSaving = false;
 		}
 		
 		public override void Load (string fileName)
 		{
-			isSaving = true;
 			se.Buffer.LoadFile (fileName, Vfs.GetMimeType (fileName));
 			ContentName = fileName;
 			InitializeFormatter ();
-			isSaving = false;
 		}
 		
 		public void InitializeFormatter()




More information about the Monodevelop-patches-list mailing list