Skip to content

Commit

Permalink
Fixed groups exception
Browse files Browse the repository at this point in the history
  • Loading branch information
flabbet committed Dec 12, 2021
1 parent 70d0b28 commit 34318c0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions PixiEditor/Models/DataHolders/WpfObservableRangeCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace PixiEditor.Models.DataHolders
{
public class WpfObservableRangeCollection<T> : RangeObservableCollection<T>
{
public bool SuppressNotify { get; set; } = false;
DeferredEventsCollection _deferredEvents;

public WpfObservableRangeCollection()
Expand All @@ -37,6 +38,7 @@ public WpfObservableRangeCollection(List<T> list) : base(list)
/// </remarks>
protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
{
if (SuppressNotify) return;
var _deferredEvents = (ICollection<NotifyCollectionChangedEventArgs>) typeof(RangeObservableCollection<T>)
.GetField("_deferredEvents", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(this);
if (_deferredEvents != null)
Expand Down
4 changes: 4 additions & 0 deletions PixiEditor/Models/Undo/StorageBasedChange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,13 @@ public static void BasicUndoProcess(Layer[] layers, UndoLayer[] data, object[] a
for (int i = 0; i < layers.Length; i++)
{
Layer layer = layers[i];
document.Layers.SuppressNotify = true;
document.Layers.RemoveAt(data[i].LayerIndex);
document.Layers.SuppressNotify = false;

document.Layers.Insert(data[i].LayerIndex, layer);


if (data[i].IsActive)
{
document.SetMainActiveLayer(data[i].LayerIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ public void NewLayer(object parameter)
doc.MoveLayerInStructure(doc.Layers[^1].LayerGuid, lastActiveLayerGuid, true);
Guid? parent = parameter is Layer or LayerStructureItemContainer ? activeLayerParent?.GroupGuid : activeLayerParent.Parent?.GroupGuid;
doc.LayerStructure.AssignParent(doc.ActiveLayerGuid, parent);
doc.UndoManager.UndoStack.Pop();
}
if (control != null)
{
Expand Down

0 comments on commit 34318c0

Please sign in to comment.