Fix block group changes not affecting script (#101)

This commit is contained in:
azakhi 2018-11-27 00:24:27 +03:00 committed by Ben Wallis
parent e516ded476
commit 124786dd0d
2 changed files with 21 additions and 1 deletions

View File

@ -28,7 +28,6 @@ namespace Filtration.ViewModels
ParentGroup = parent; ParentGroup = parent;
Advanced = itemFilterBlockGroup.Advanced; Advanced = itemFilterBlockGroup.Advanced;
SourceBlockGroup = itemFilterBlockGroup; SourceBlockGroup = itemFilterBlockGroup;
SourceBlockGroup.ClearStatusChangeSubscribers();
SourceBlockGroup.BlockGroupStatusChanged += OnSourceBlockGroupStatusChanged; SourceBlockGroup.BlockGroupStatusChanged += OnSourceBlockGroupStatusChanged;
IsShowChecked = itemFilterBlockGroup.IsShowChecked; IsShowChecked = itemFilterBlockGroup.IsShowChecked;
IsEnableChecked = itemFilterBlockGroup.IsEnableChecked; IsEnableChecked = itemFilterBlockGroup.IsEnableChecked;
@ -256,5 +255,18 @@ namespace Filtration.ViewModels
IsEnableChecked = SourceBlockGroup.IsEnableChecked; IsEnableChecked = SourceBlockGroup.IsEnableChecked;
} }
} }
public void ClearStatusChangeSubscriptions()
{
if (SourceBlockGroup != null)
{
SourceBlockGroup.BlockGroupStatusChanged -= OnSourceBlockGroupStatusChanged;
}
foreach (var child in ChildGroups)
{
child.ClearStatusChangeSubscriptions();
}
}
} }
} }

View File

@ -107,6 +107,14 @@ namespace Filtration.ViewModels.ToolPanes
private ObservableCollection<ItemFilterBlockGroupViewModel> RebuildBlockGroupViewModels(bool showAdvanced) private ObservableCollection<ItemFilterBlockGroupViewModel> RebuildBlockGroupViewModels(bool showAdvanced)
{ {
if (BlockGroupViewModels != null)
{
foreach (var viewModel in BlockGroupViewModels)
{
viewModel.ClearStatusChangeSubscriptions();
}
}
// This assumes that there will only ever be a single root node. // This assumes that there will only ever be a single root node.
return new ObservableCollection<ItemFilterBlockGroupViewModel> return new ObservableCollection<ItemFilterBlockGroupViewModel>
( (