From 3e0adfbc4e800f8ce34913a6cfcaf968cf7a8196 Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Thu, 7 Apr 2016 22:03:23 +0200 Subject: [PATCH] Merged in GZDB r2498. --- .../Controls/ScriptEditorPreviewControl.cs | 5 +- Source/Core/Data/DataManager.cs | 3 +- Source/Core/Data/ImageData.cs | 8 ++- Source/Core/Rendering/D3DDevice.cs | 70 +++++++++++-------- 4 files changed, 54 insertions(+), 32 deletions(-) diff --git a/Source/Core/Controls/ScriptEditorPreviewControl.cs b/Source/Core/Controls/ScriptEditorPreviewControl.cs index 4b566ff..c434fb3 100644 --- a/Source/Core/Controls/ScriptEditorPreviewControl.cs +++ b/Source/Core/Controls/ScriptEditorPreviewControl.cs @@ -289,7 +289,10 @@ namespace CodeImp.DoomBuilder.Controls { // Instruct the lexer to calculate folding scriptedit.SetProperty("fold", "1"); - scriptedit.SetProperty("fold.compact", "1"); + scriptedit.SetProperty("fold.compact", "0"); // 1 = folds blank lines + scriptedit.SetProperty("fold.comment", "1"); // Enable block comment folding + scriptedit.SetProperty("fold.preprocessor", "1"); // Enable #region folding + scriptedit.SetFoldFlags(FoldFlags.LineAfterContracted); // Draw line below if not expanded // Configure a margin to display folding symbols scriptedit.Margins[2].Type = MarginType.Symbol; diff --git a/Source/Core/Data/DataManager.cs b/Source/Core/Data/DataManager.cs index 93adfd4..b4debfd 100644 --- a/Source/Core/Data/DataManager.cs +++ b/Source/Core/Data/DataManager.cs @@ -532,7 +532,8 @@ namespace CodeImp.DoomBuilder.Data foreach(KeyValuePair i in textures) i.Value.Dispose(); foreach(KeyValuePair i in flats) i.Value.Dispose(); foreach(KeyValuePair i in sprites) i.Value.Dispose(); - palette = null; + foreach (KeyValuePair i in internalsprites) i.Value.Dispose(); //mxd + palette = null; //mxd. Dispose models foreach(KeyValuePair i in modeldefentries) i.Value.Dispose(); diff --git a/Source/Core/Data/ImageData.cs b/Source/Core/Data/ImageData.cs index fbace60..8fc9610 100644 --- a/Source/Core/Data/ImageData.cs +++ b/Source/Core/Data/ImageData.cs @@ -462,8 +462,12 @@ namespace CodeImp.DoomBuilder.Data if((width != texture.GetLevelDescription(0).Width) || (height != texture.GetLevelDescription(0).Height)) throw new Exception("Could not create a texture with the same size as the image."); } - } - } + +#if DEBUG + texture.Tag = name; //mxd. Helps with tracking undisposed resources... +#endif + } + } } // This updates a dynamic texture diff --git a/Source/Core/Rendering/D3DDevice.cs b/Source/Core/Rendering/D3DDevice.cs index bccc37b..a4fa7c8 100644 --- a/Source/Core/Rendering/D3DDevice.cs +++ b/Source/Core/Rendering/D3DDevice.cs @@ -18,13 +18,13 @@ using System; using System.Collections.Generic; -using System.Windows.Forms; using System.Drawing; -using SlimDX.Direct3D9; +using System.Windows.Forms; +using CodeImp.DoomBuilder.Controls; +using CodeImp.DoomBuilder.Data; using CodeImp.DoomBuilder.Geometry; using SlimDX; -using CodeImp.DoomBuilder.Data; -using CodeImp.DoomBuilder.Controls; +using SlimDX.Direct3D9; #endregion @@ -100,28 +100,42 @@ namespace CodeImp.DoomBuilder.Rendering // Disposer public void Dispose() { - // Not already disposed? - if(!isdisposed) - { - // Clean up - foreach(ID3DResource res in resources) res.UnloadResource(); - if(shaders != null) shaders.Dispose(); - rendertarget = null; - if(backbuffer != null) backbuffer.Dispose(); - if(depthbuffer != null) depthbuffer.Dispose(); - if (device != null) - { - device.Reset(new PresentParameters()); //mxd. Some video memory is not freed without this line if Visual mode was visited - device.Dispose(); - } + // Not already disposed? + if (!isdisposed) + { + // Clean up + foreach (ID3DResource res in resources) res.UnloadResource(); + if (shaders != null) shaders.Dispose(); + rendertarget = null; + if (backbuffer != null) backbuffer.Dispose(); + if (depthbuffer != null) depthbuffer.Dispose(); if (font != null) font.Dispose(); - if(fonttexture != null) fonttexture.Dispose(); - isrendering = false; //mxd - - // Done - isdisposed = true; - } - } + if (fonttexture != null) fonttexture.Dispose(); + if (device != null) device.Dispose(); + + if (ObjectTable.Objects.Count > 1) //mxd. Direct3D itself is not disposed while the editor is running + { + //mxd. Get rid of any remaining D3D objects... + foreach (ComObject o in ObjectTable.Objects) + { + if (o is Direct3D) continue; // Don't dispose the device itself... + General.WriteLogLine("WARNING: D3D resource " + o + + (o.Tag != null ? " (" + o.Tag + ")" : string.Empty) + " was not disposed properly!" + + (o.CreationSource != null ? " Stack trace: " + o.CreationSource : string.Empty)); + o.Dispose(); + } + +#if DEBUG + General.ShowWarningMessage("Some D3D resources were not disposed properly! See the event log for more details.", + MessageBoxButtons.OK); +#endif + } + + // Done + isrendering = false; //mxd + isdisposed = true; + } + } #endregion @@ -314,9 +328,9 @@ namespace CodeImp.DoomBuilder.Rendering displaypp.BackBufferWidth = rendertarget.ClientSize.Width; displaypp.BackBufferHeight = rendertarget.ClientSize.Height; displaypp.EnableAutoDepthStencil = true; - displaypp.AutoDepthStencilFormat = Format.D16; - displaypp.Multisample = MultisampleType.None; - displaypp.PresentationInterval = PresentInterval.Immediate; + displaypp.AutoDepthStencilFormat = Format.D24X8; //Format.D16; + displaypp.Multisample = MultisampleType.None; + displaypp.PresentationInterval = PresentInterval.Immediate; // Return result return displaypp;