Skip to content

Commit

Permalink
fix: Fix crash when editing properties in the node editor
Browse files Browse the repository at this point in the history
  • Loading branch information
yuto-trd committed Oct 29, 2024
1 parent 8f53e4c commit 922d2b2
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/Beutl/ViewModels/NodeTree/NodeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace Beutl.ViewModels.NodeTree;

public sealed class NodeViewModel : IDisposable, IJsonSerializable
public sealed class NodeViewModel : IDisposable, IJsonSerializable, IPropertyEditorContextVisitor, IServiceProvider
{
private readonly CompositeDisposable _disposables = [];
private readonly string _defaultName;
Expand Down Expand Up @@ -178,7 +178,7 @@ private NodeItemViewModel CreateNodeItemViewModel(IPropertyAdapter[] atmp, INode
(_, PropertyEditorExtension ext) = PropertyEditorService.MatchProperty(atmp);
ext?.TryCreateContextForNode(atmp, out context);
}

context?.Accept(this);
return CreateNodeItemViewModelCore(item, context);
}

Expand Down Expand Up @@ -252,4 +252,18 @@ public void ReadFromJson(JsonObject json)
}
}
}

public void Visit(IPropertyEditorContext context)
{
}

public object? GetService(Type serviceType)
{
if (serviceType == typeof(Node))
{
return Node;
}

return EditorContext.GetService(serviceType);
}
}

0 comments on commit 922d2b2

Please sign in to comment.