From c6eed73269be5dfacc52c0b209637b1ed51877b2 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Wed, 2 Jun 2021 01:48:52 -0400 Subject: [PATCH] DataFormat subclasses MUST create a new instance of DataFormatReference, otherwise it breaks superclasses --- .../DataFormats/JSON/JSONDataFormat.cs | 2 +- .../Multimedia3D/Model/Wavefront/OBJDataFormat.cs | 2 +- .../DataFormats/SourceCode/CodeDataFormat.cs | 10 +++++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Libraries/UniversalEditor.Essential/DataFormats/JSON/JSONDataFormat.cs b/Libraries/UniversalEditor.Essential/DataFormats/JSON/JSONDataFormat.cs index 2e24c78a..0232ccf3 100644 --- a/Libraries/UniversalEditor.Essential/DataFormats/JSON/JSONDataFormat.cs +++ b/Libraries/UniversalEditor.Essential/DataFormats/JSON/JSONDataFormat.cs @@ -41,7 +41,7 @@ namespace UniversalEditor.DataFormats.JSON { if (_dfr == null) { - _dfr = base.MakeReferenceInternal(); + _dfr = new DataFormatReference(GetType()); _dfr.Capabilities.Add(typeof(JSONObjectModel), DataFormatCapabilities.All); } return _dfr; diff --git a/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Wavefront/OBJDataFormat.cs b/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Wavefront/OBJDataFormat.cs index 2879e0de..a9075566 100644 --- a/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Wavefront/OBJDataFormat.cs +++ b/Plugins/UniversalEditor.Plugins.Multimedia3D/DataFormats/Multimedia3D/Model/Wavefront/OBJDataFormat.cs @@ -38,7 +38,7 @@ namespace UniversalEditor.DataFormats.Multimedia3D.Model.Wavefront { if (_dfr == null) { - _dfr = base.MakeReferenceInternal(); + _dfr = new DataFormatReference(GetType()); _dfr.Capabilities.Add(typeof(ModelObjectModel), DataFormatCapabilities.All); } return _dfr; diff --git a/Plugins/UniversalEditor.Plugins.SoftwareDevelopment/DataFormats/SourceCode/CodeDataFormat.cs b/Plugins/UniversalEditor.Plugins.SoftwareDevelopment/DataFormats/SourceCode/CodeDataFormat.cs index ed67052d..c80a790c 100644 --- a/Plugins/UniversalEditor.Plugins.SoftwareDevelopment/DataFormats/SourceCode/CodeDataFormat.cs +++ b/Plugins/UniversalEditor.Plugins.SoftwareDevelopment/DataFormats/SourceCode/CodeDataFormat.cs @@ -39,11 +39,15 @@ namespace UniversalEditor.DataFormats.SourceCode /// public abstract class CodeDataFormat : PlainTextDataFormat { + private static DataFormatReference _dfr = null; protected override DataFormatReference MakeReferenceInternal() { - DataFormatReference dfr = base.MakeReferenceInternal(); - dfr.Capabilities.Add(typeof(CodeObjectModel), DataFormatCapabilities.All); - return dfr; + if (_dfr == null) + { + _dfr = new DataFormatReference(GetType()); + _dfr.Capabilities.Add(typeof(CodeObjectModel), DataFormatCapabilities.All); + } + return _dfr; } protected override void BeforeLoadInternal(Stack objectModels)