• R/O
  • HTTP
  • SSH
  • HTTPS

FooEditor: Commit


Commit MetaInfo

Revision3e3c7603eeead69f3277c93440bb801f7cc1d694 (tree)
Time2019-03-10 00:32:39
Authortest <test@yaho...>
Commitertest

Log Message

自動保存タイマーを動かし続けると環境によっては落ちる可能性があった

Change Summary

Incremental Difference

--- a/UWP/FooEditor.UWP/Models/DocumentCollection.cs
+++ b/UWP/FooEditor.UWP/Models/DocumentCollection.cs
@@ -209,29 +209,20 @@ namespace FooEditor.UWP.Models
209209
210210 public static string collection_name = "DocumentCollection.xml";
211211
212- SemaphoreSlim sem = new SemaphoreSlim(1, 1);
213212 public async Task SaveDocumentCollection()
214213 {
215214 if (this.Count > 0 && this.hasDirtyDoc)
216215 {
217- try
216+ FileModel file = await FileModel.CreateFileModelFromAppSetting(collection_name);
217+ using (Stream fs = await file.GetWriteStreamAsync())
218218 {
219- await sem.WaitAsync().ConfigureAwait(false);
220- FileModel file = await FileModel.CreateFileModelFromAppSetting(collection_name);
221- using (Stream fs = await file.GetWriteStreamAsync())
219+ DataContractSerializer serializer = new DataContractSerializer(typeof(DocumentCollection));
220+ serializer.WriteObject(fs, this);
221+ foreach (var doc in this)
222222 {
223- DataContractSerializer serializer = new DataContractSerializer(typeof(DocumentCollection));
224- serializer.WriteObject(fs, this);
225- foreach (var doc in this)
226- {
227- await doc.DocumentModel.SaveCurrentFile();
228- }
229- System.Diagnostics.Debug.WriteLine("AutoSaved");
223+ await doc.DocumentModel.SaveCurrentFile();
230224 }
231- }
232- finally
233- {
234- sem.Release();
225+ System.Diagnostics.Debug.WriteLine("AutoSaved");
235226 }
236227 }
237228 }
--- a/UWP/FooEditor.UWP/ViewModels/MainPageViewModel.cs
+++ b/UWP/FooEditor.UWP/ViewModels/MainPageViewModel.cs
@@ -107,8 +107,13 @@ namespace FooEditor.UWP.ViewModels
107107 private async void Timer_Tick(object sender, object e)
108108 {
109109 if(AppSettings.Current.EnableAutoSave)
110+ {
111+ //再入されるとまずい
112+ this.timer.Stop();
110113 await this.DocumentList.SaveDocumentCollection();
111- if(this.IsRequierDelayCleanStatusMessage)
114+ this.timer.Start();
115+ }
116+ if (this.IsRequierDelayCleanStatusMessage)
112117 {
113118 this.StatusMessage = string.Empty;
114119 this.IsRequierDelayCleanStatusMessage = false;
Show on old repository browser