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

@@ -33,19 +33,19 @@ namespace OpenRA.Primitives
{
protected IDictionary<TKey, TValue> innerDict;
public event Action<object> OnAdd = k => { };
public event Action<object> OnRemove = k => { };
public event Action<IObservableCollection, object> OnAdd = (x, k) => { };
public event Action<IObservableCollection, object> OnRemove = (x, k) => { };
// TODO Workaround for https://github.com/OpenRA/OpenRA/issues/6101
#pragma warning disable 67
public event Action<int> OnRemoveAt = i => { };
public event Action<object, object> OnSet = (o, n) => { };
public event Action<IObservableCollection, int> OnRemoveAt = (x, i) => { };
public event Action<IObservableCollection, object, object> OnSet = (x, o, n) => { };
#pragma warning restore
public event Action OnRefresh = () => { };
public event Action<IObservableCollection> OnRefresh = x => { };
protected void FireOnRefresh()
{
OnRefresh();
OnRefresh(this);
}
protected ObservableDictionary() { }
@@ -58,14 +58,14 @@ namespace OpenRA.Primitives
public virtual void Add(TKey key, TValue value)
{
innerDict.Add(key, value);
OnAdd(key);
OnAdd(this, key);
}
public bool Remove(TKey key)
{
var found = innerDict.Remove(key);
if (found)
OnRemove(key);
OnRemove(this, key);
return found;
}
@@ -91,7 +91,7 @@ namespace OpenRA.Primitives
public void Clear()
{
innerDict.Clear();
OnRefresh();
OnRefresh(this);
}
public int Count