DataFormat subclasses MUST create a new instance of DataFormatReference, otherwise it breaks superclasses

This commit is contained in:
Michael Becker 2021-06-02 01:48:52 -04:00
parent 2a64f97317
commit c6eed73269
No known key found for this signature in database
GPG Key ID: 98C333A81F18C22C
3 changed files with 9 additions and 5 deletions

View File

@ -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;

View File

@ -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;

View File

@ -39,11 +39,15 @@ namespace UniversalEditor.DataFormats.SourceCode
/// </summary>
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<ObjectModel> objectModels)