OSDN Git Service

ドキュメントが不要になったらレイアウトキャッシュをクリアしないといけなかった
authorkonekoneko <test2214@hotmail.co.jp>
Fri, 14 Oct 2016 20:01:59 +0000 (01:31 +0530)
committerkonekoneko <test2214@hotmail.co.jp>
Fri, 14 Oct 2016 20:01:59 +0000 (01:31 +0530)
Core/Document.cs

index 09b7c9b..de0d471 100644 (file)
@@ -135,7 +135,7 @@ namespace FooEditEngine
     /// ドキュメントの管理を行う
     /// </summary>
     /// <remarks>この型のすべてのメソッド・プロパティはスレッドセーフです</remarks>
-    public sealed class Document : IEnumerable<char>, IRandomEnumrator<char>
+    public sealed class Document : IEnumerable<char>, IRandomEnumrator<char>, IDisposable
     {
         Regex regex;
         Match match;
@@ -1237,6 +1237,32 @@ namespace FooEditEngine
             if(this.FireUpdateEvent)
                 this.Update(this, e);
         }
+
+        #region IDisposable Support
+        private bool disposedValue = false; // 重複する呼び出しを検出するには
+
+        void Dispose(bool disposing)
+        {
+            if (!disposedValue)
+            {
+                if (disposing)
+                {
+                    this.buffer.Clear();
+                    this.LayoutLines.Clear();
+                    this.buffer = null;
+                    this._LayoutLines = null;
+                }
+
+                disposedValue = true;
+            }
+        }
+
+        // このコードは、破棄可能なパターンを正しく実装できるように追加されました。
+        public void Dispose()
+        {
+            Dispose(true);
+        }
+        #endregion
     }
 
     /// <summary>