mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 01:43:20 +08:00
Dispose enumerators for safety
This commit is contained in:
parent
4e4fe5cc90
commit
2dee5e03e3
@ -39,14 +39,15 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
{
|
{
|
||||||
DrawableHitObject blockingObject = null;
|
DrawableHitObject blockingObject = null;
|
||||||
|
|
||||||
var enumerator = new HitObjectEnumerator(hitObjectContainer, hitObject.HitObject.StartTime);
|
using (var enumerator = new HitObjectEnumerator(hitObjectContainer, hitObject.HitObject.StartTime))
|
||||||
|
|
||||||
while (enumerator.MoveNext())
|
|
||||||
{
|
{
|
||||||
Debug.Assert(enumerator.Current != null);
|
while (enumerator.MoveNext())
|
||||||
|
{
|
||||||
|
Debug.Assert(enumerator.Current != null);
|
||||||
|
|
||||||
if (hitObjectCanBlockFutureHits(enumerator.Current))
|
if (hitObjectCanBlockFutureHits(enumerator.Current))
|
||||||
blockingObject = enumerator.Current;
|
blockingObject = enumerator.Current;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is no previous hitobject, allow the hit.
|
// If there is no previous hitobject, allow the hit.
|
||||||
@ -76,17 +77,18 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
if (!IsHittable(hitObject, hitObject.HitObject.StartTime + hitObject.Result.TimeOffset))
|
if (!IsHittable(hitObject, hitObject.HitObject.StartTime + hitObject.Result.TimeOffset))
|
||||||
throw new InvalidOperationException($"A {hitObject} was hit before it become hittable!");
|
throw new InvalidOperationException($"A {hitObject} was hit before it become hittable!");
|
||||||
|
|
||||||
var enumerator = new HitObjectEnumerator(hitObjectContainer, hitObject.HitObject.StartTime);
|
using (var enumerator = new HitObjectEnumerator(hitObjectContainer, hitObject.HitObject.StartTime))
|
||||||
|
|
||||||
while (enumerator.MoveNext())
|
|
||||||
{
|
{
|
||||||
Debug.Assert(enumerator.Current != null);
|
while (enumerator.MoveNext())
|
||||||
|
{
|
||||||
|
Debug.Assert(enumerator.Current != null);
|
||||||
|
|
||||||
if (enumerator.Current.Judged)
|
if (enumerator.Current.Judged)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (hitObjectCanBlockFutureHits(enumerator.Current))
|
if (hitObjectCanBlockFutureHits(enumerator.Current))
|
||||||
((DrawableOsuHitObject)enumerator.Current).MissForcefully();
|
((DrawableOsuHitObject)enumerator.Current).MissForcefully();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,6 +182,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
hitObjectEnumerator?.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user