Fix frame end task race condition in ScrollPanelWidget

This commit is contained in:
Curtis Shmyr
2016-11-13 07:09:47 +00:00
committed by Paul Chote
parent 9d7413ab3d
commit 33e1a6b2dd
5 changed files with 60 additions and 41 deletions

View File

@@ -18,15 +18,15 @@ namespace OpenRA.Primitives
{
public class ObservableCollection<T> : Collection<T>, IObservableCollection
{
public event Action<object> OnAdd = k => { };
public event Action<IObservableCollection, object> OnAdd = (x, k) => { };
// TODO Workaround for https://github.com/OpenRA/OpenRA/issues/6101
#pragma warning disable 67
public event Action<object> OnRemove = k => { };
public event Action<IObservableCollection, object> OnRemove = (x, k) => { };
#pragma warning restore
public event Action<int> OnRemoveAt = i => { };
public event Action<object, object> OnSet = (o, n) => { };
public event Action OnRefresh = () => { };
public event Action<IObservableCollection, int> OnRemoveAt = (x, i) => { };
public event Action<IObservableCollection, object, object> OnSet = (x, o, n) => { };
public event Action<IObservableCollection> OnRefresh = x => { };
public ObservableCollection() { }
public ObservableCollection(IList<T> list) : base(list) { }
@@ -35,25 +35,25 @@ namespace OpenRA.Primitives
{
var old = this[index];
base.SetItem(index, item);
OnSet(old, item);
OnSet(this, old, item);
}
protected override void InsertItem(int index, T item)
{
base.InsertItem(index, item);
OnAdd(item);
OnAdd(this, item);
}
protected override void ClearItems()
{
base.ClearItems();
OnRefresh();
OnRefresh(this);
}
protected override void RemoveItem(int index)
{
base.RemoveItem(index);
OnRemoveAt(index);
OnRemoveAt(this, index);
}
public IEnumerable ObservedItems