OSDN Git Service

メモリーリークが発生するのでsharpdxだけ4.0.1に戻した
authortest <test@yahoo.co.jp>
Tue, 9 Apr 2019 11:26:26 +0000 (20:26 +0900)
committertest <test@yahoo.co.jp>
Tue, 9 Apr 2019 11:26:26 +0000 (20:26 +0900)
Core/Direct2D/InlineChar.cs
Core/Direct2D/MultiSet.cs
UWP/FooEditEngine.UWP/Direct2D/D2DRenderBase.cs
UWP/FooEditEngine.UWP/FooEditEngine.UWP.csproj
WPF/FooEditEngine/Direct2D/D2DRender.cs
WPF/FooEditEngine/FooEditEngine.csproj

index 935acca..642cfb3 100644 (file)
@@ -15,14 +15,14 @@ using DW = SharpDX.DirectWrite;
 
 namespace FooEditEngine
 {
-    sealed class InlineChar : CallbackBase, DW.InlineObject
+    sealed class InlineChar : DW.InlineObject
     {
         DW.TextLayout Layout;
         ColorBrushCollection brushes;
         Color4 DefaultFore;
-        public InlineChar(DW.Factory factory, DW.TextFormat format,ColorBrushCollection brushes, Color4 Fore, char c)
+        public InlineChar(DW.Factory factory, DW.TextFormat format, ColorBrushCollection brushes, Color4 Fore, char c)
         {
-            this.Layout = new DW.TextLayout(factory,c.ToString(),format,float.MaxValue,float.MaxValue);
+            this.Layout = new DW.TextLayout(factory, c.ToString(), format, float.MaxValue, float.MaxValue);
             this.Layout.ReadingDirection = DW.ReadingDirection.LeftToRight;
             this.AlternativeChar = c;
             this.brushes = brushes;
@@ -74,7 +74,7 @@ namespace FooEditEngine
         {
             get
             {
-                if(_Metrics == null)
+                if (_Metrics == null)
                 {
                     DW.InlineObjectMetrics value = new DW.InlineObjectMetrics();
                     value.Height = this.Layout.Metrics.Height;
@@ -92,7 +92,7 @@ namespace FooEditEngine
         {
             get
             {
-                if(_OverhangMetrics == null)
+                if (_OverhangMetrics == null)
                 {
                     DW.OverhangMetrics value = new DW.OverhangMetrics();
                     DW.TextMetrics metrics = this.Layout.Metrics;
@@ -112,22 +112,20 @@ namespace FooEditEngine
             set;
         }
 
-        //disposeしてはいけないらしい
-        //protected override void Dispose(bool disposing)
-        //{
-        //    base.Dispose(disposing);
-        //    this.Layout.Dispose();
-        //}
-
+        public void Dispose()
+        {
+            this.Layout.Dispose();
+            return;
+        }
     }
 
-    sealed class InlineTab : CallbackBase,DW.InlineObject
+    sealed class InlineTab : DW.InlineObject
     {
         double _TabWidth;
         double LineHeight;
         ColorBrushCollection brushes;
         Color4 DefaultFore;
-        public InlineTab(ColorBrushCollection brushes, Color4 Fore, double witdh,double lineHeight)
+        public InlineTab(ColorBrushCollection brushes, Color4 Fore, double witdh, double lineHeight)
         {
             this._TabWidth = witdh;
             this.LineHeight = lineHeight;
@@ -140,7 +138,7 @@ namespace FooEditEngine
         {
             get
             {
-                if(_Metrics == null)
+                if (_Metrics == null)
                 {
                     DW.InlineObjectMetrics value = new DW.InlineObjectMetrics();
                     value.Width = (float)this._TabWidth;
@@ -218,5 +216,8 @@ namespace FooEditEngine
             set;
         }
 
+        public void Dispose()
+        {
+        }
     }
 }
index 801d279..963f4da 100644 (file)
@@ -47,7 +47,7 @@ namespace FooEditEngine
         {
             if (c == '\t')
             {
-                this.InlineTabs = new MultiSet<double,InlineTab>();
+                this.InlineTabs = new MultiSet<double, InlineTab>();
             }
             else
             {
@@ -104,13 +104,13 @@ namespace FooEditEngine
             }
             set
             {
-                this._TabWidth = value; 
-                if(this.InlineTabs != null)
+                this._TabWidth = value;
+                if (this.InlineTabs != null)
                     this.InlineTabs.Clear();
             }
         }
 
-        public DW.InlineObject Get(MyTextLayout layout,int index, string str)
+        public DW.InlineObject Get(MyTextLayout layout, int index, string str)
         {
             if (str[index] == '\t')
             {
@@ -130,7 +130,7 @@ namespace FooEditEngine
                     collection = new List<InlineTab>();
                     D2D.SolidColorBrush brush = this.Brushes.Get(this.Fore);
                     for (int i = 0; i < DuplicateCount; i++)
-                        collection.Add(new InlineTab(this.Brushes, this.Fore, width,layout.Height));
+                        collection.Add(new InlineTab(this.Brushes, this.Fore, width, layout.Height));
                     this.InlineTabs.Add(width, collection);
                 }
                 return collection[index % DuplicateCount];
@@ -146,9 +146,9 @@ namespace FooEditEngine
 
         public void Clear()
         {
-            if(this.InlineChars != null)
+            if (this.InlineChars != null)
                 this.InlineChars.Clear();
-            if(this.InlineTabs != null)
+            if (this.InlineTabs != null)
                 this.InlineTabs.Clear();
         }
 
@@ -212,7 +212,7 @@ namespace FooEditEngine
             return this.Collection.TryGetValue(key, out value);
         }
 
-        public J Get(T key,int index)
+        public J Get(T key, int index)
         {
             return this.Collection[key][index];
         }
@@ -228,12 +228,9 @@ namespace FooEditEngine
 
         public void Clear()
         {
-            /*
-             * Dispose()すると落ちる
             foreach (List<J> list in this.Collection.Values)
                 foreach (J value in list)
                     value.Dispose();
-            */
             this.Collection.Clear();
         }
 
index 0ee7b55..56370cd 100644 (file)
@@ -24,7 +24,7 @@ using FooEditEngine.UWP;
 
 namespace FooEditEngine
 {
-    class D2DRenderBase: D2DRenderCommon,IDisposable
+    class D2DRenderBase : D2DRenderCommon, IDisposable
     {
         public new const int MiniumeWidth = 40;    //これ以上ないと誤操作が起こる
 
@@ -93,9 +93,8 @@ namespace FooEditEngine
         {
             this.Brushes.Clear();
             this.Strokes.Clear();
-            //ここでDispose()する必要はない。すると落ちる
-            //if (this.textRender != null)
-            //    this.textRender.Dispose();
+            if (this.textRender != null)
+                this.textRender.Dispose();
             if (this.D2DDevice != null)
                 this.D2DDevice.Dispose();
             if (this.D2DContext != null)
@@ -181,7 +180,7 @@ namespace FooEditEngine
             return false;
         }
 
-        public void DrawOneLine(Document doc,LineToIndexTable lti, int row, double x, double y)
+        public void DrawOneLine(Document doc, LineToIndexTable lti, int row, double x, double y)
         {
             this.DrawOneLine(doc,
                 lti,
index 247bece..74060a2 100644 (file)
       <Version>5.0.0</Version>
     </PackageReference>
     <PackageReference Include="SharpDX">
-      <Version>4.2.0</Version>
+      <Version>4.0.1</Version>
     </PackageReference>
     <PackageReference Include="SharpDX.Direct2D1">
-      <Version>4.2.0</Version>
+      <Version>4.0.1</Version>
     </PackageReference>
     <PackageReference Include="SharpDX.Direct3D11">
-      <Version>4.2.0</Version>
+      <Version>4.0.1</Version>
     </PackageReference>
     <PackageReference Include="SharpDX.DXGI">
-      <Version>4.2.0</Version>
+      <Version>4.0.1</Version>
     </PackageReference>
     <PackageReference Include="SharpDX.Mathematics">
-      <Version>4.2.0</Version>
+      <Version>4.0.1</Version>
     </PackageReference>
   </ItemGroup>
   <ItemGroup>
index a492978..54d5c74 100644 (file)
@@ -44,7 +44,7 @@ namespace FooEditEngine.WPF
         FontStyle fontStyle;
         D3DImage imageSource;
 
-        public D2DRender(FooTextBox textbox, double width, double height,Image image)
+        public D2DRender(FooTextBox textbox, double width, double height, Image image)
         {
             this.fontFamily = textbox.FontFamily;
             this.fontSize = textbox.FontSize;
@@ -111,7 +111,7 @@ namespace FooEditEngine.WPF
             set
             {
                 this.fontWeigth = value;
-                this.InitTextFormat(this.fontFamily.Source, (float)this.fontSize, this.GetDWFontWeigth(value),this.GetDWFontStyle(this.fontStyle));
+                this.InitTextFormat(this.fontFamily.Source, (float)this.fontSize, this.GetDWFontWeigth(value), this.GetDWFontStyle(this.fontStyle));
             }
         }
 
@@ -152,7 +152,7 @@ namespace FooEditEngine.WPF
             this.ConstructRenderAndResource(width, height);
         }
 
-        public void DrawContent(EditView view,bool IsEnabled,Rectangle updateRect)
+        public void DrawContent(EditView view, bool IsEnabled, Rectangle updateRect)
         {
             if (this.imageSource.IsFrontBufferAvailable)
             {
@@ -172,7 +172,7 @@ namespace FooEditEngine.WPF
             }
         }
 
-        public void DrawOneLine(Document doc,LineToIndexTable lti, int row, double x, double y)
+        public void DrawOneLine(Document doc, LineToIndexTable lti, int row, double x, double y)
         {
             PreDrawOneLineHandler PreDrawOneLine = null;
 
@@ -188,7 +188,7 @@ namespace FooEditEngine.WPF
                 );
         }
 
-        private void DrawImeConversionLine(MyTextLayout layout,LineToIndexTable lti,int row,double x,double y)
+        private void DrawImeConversionLine(MyTextLayout layout, LineToIndexTable lti, int row, double x, double y)
         {
             using (Unlocker locker = this.store.LockDocument(false))
             {
@@ -245,7 +245,7 @@ namespace FooEditEngine.WPF
         private Color4? GetColor4(TF_DA_COLOR cr)
         {
             COLORREF colorref;
-            switch(cr.type)
+            switch (cr.type)
             {
                 case TF_DA_COLORTYPE.TF_CT_SYSCOLOR:
                     colorref = new COLORREF(NativeMethods.GetSysColor((int)cr.indexOrColorRef));
@@ -428,9 +428,8 @@ namespace FooEditEngine.WPF
                 this.cachedBitMap.Dispose();
             this.Brushes.Clear();
             this.Strokes.Clear();
-            //ここでDispose()すると落ちる
-            //if (this.textRender != null)
-            //    this.textRender.Dispose();
+            if (this.textRender != null)
+                this.textRender.Dispose();
             if (this.texture != null)
                 this.texture.Dispose();
             if (this.surface != null)
index 850ec6c..f99d2a9 100644 (file)
       <Version>5.0.0</Version>
     </PackageReference>
     <PackageReference Include="SharpDX.Direct2D1">
-      <Version>4.2.0</Version>
+      <Version>4.0.1</Version>
     </PackageReference>
     <PackageReference Include="SharpDX.Direct3D11">
-      <Version>4.2.0</Version>
+      <Version>4.0.1</Version>
     </PackageReference>
     <PackageReference Include="SharpDX.Direct3D9">
-      <Version>4.2.0</Version>
+      <Version>4.0.1</Version>
     </PackageReference>
     <PackageReference Include="SharpDX.Mathematics">
-      <Version>4.2.0</Version>
+      <Version>4.0.1</Version>
     </PackageReference>
   </ItemGroup>
   <Import Project="..\..\Core\Core.projitems" Label="Shared" />