mirror of
https://github.com/ppy/osu
synced 2024-12-16 11:56:31 +00:00
Merge pull request #398 from peppy/fix-memory-leak
Fix memory leak from Player's InputManager.
This commit is contained in:
commit
6a2d1f92e5
@ -59,7 +59,7 @@ namespace osu.Game.Tests.Beatmaps.IO
|
||||
if (!importer.ImportAsync(osz_path).Wait(1000))
|
||||
Assert.Fail(@"IPC took too long to send");
|
||||
|
||||
ensureLoaded(osu, 10000);
|
||||
ensureLoaded(osu);
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,23 +77,23 @@ namespace osu.Game.Tests.Beatmaps.IO
|
||||
return osu;
|
||||
}
|
||||
|
||||
private void ensureLoaded(OsuGameBase osu, int timeout = 100)
|
||||
private void ensureLoaded(OsuGameBase osu, int timeout = 10000)
|
||||
{
|
||||
IEnumerable<BeatmapSetInfo> resultSets = null;
|
||||
|
||||
Action waitAction = () =>
|
||||
{
|
||||
while ((resultSets = osu.Dependencies.Get<BeatmapDatabase>()
|
||||
.Query<BeatmapSetInfo>().Where(s => s.OnlineBeatmapSetID == 241526)).Count() != 1)
|
||||
Thread.Sleep(1);
|
||||
.Query<BeatmapSetInfo>().Where(s => s.OnlineBeatmapSetID == 241526)).Count() == 0)
|
||||
Thread.Sleep(50);
|
||||
};
|
||||
|
||||
Assert.IsTrue(waitAction.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(timeout),
|
||||
@"BeatmapSet did not import to the database");
|
||||
$@"BeatmapSet did not import to the database in allocated time.");
|
||||
|
||||
//ensure we were stored to beatmap database backing...
|
||||
|
||||
Assert.IsTrue(resultSets.Count() == 1);
|
||||
Assert.IsTrue(resultSets.Count() == 1, $@"Incorrect result count found ({resultSets.Count()} but should be 1).");
|
||||
|
||||
IEnumerable<BeatmapInfo> resultBeatmaps = null;
|
||||
|
||||
@ -102,16 +102,17 @@ namespace osu.Game.Tests.Beatmaps.IO
|
||||
{
|
||||
while ((resultBeatmaps = osu.Dependencies.Get<BeatmapDatabase>()
|
||||
.Query<BeatmapInfo>().Where(s => s.OnlineBeatmapSetID == 241526 && s.BaseDifficultyID > 0)).Count() != 12)
|
||||
Thread.Sleep(1);
|
||||
Thread.Sleep(50);
|
||||
};
|
||||
|
||||
Assert.IsTrue(waitAction.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(timeout),
|
||||
@"Beatmaps did not import to the database");
|
||||
@"Beatmaps did not import to the database in allocated time");
|
||||
|
||||
//fetch children and check we can load from the post-storage path...
|
||||
var set = osu.Dependencies.Get<BeatmapDatabase>().GetChildren(resultSets.First());
|
||||
|
||||
Assert.IsTrue(set.Beatmaps.Count == resultBeatmaps.Count());
|
||||
Assert.IsTrue(set.Beatmaps.Count == resultBeatmaps.Count(),
|
||||
$@"Incorrect database beatmap count post-import ({resultBeatmaps.Count()} but should be {set.Beatmaps.Count}).");
|
||||
|
||||
foreach (BeatmapInfo b in resultBeatmaps)
|
||||
Assert.IsTrue(set.Beatmaps.Any(c => c.OnlineBeatmapID == b.OnlineBeatmapID));
|
||||
|
@ -312,6 +312,9 @@ namespace osu.Game.Screens.Play
|
||||
}
|
||||
else
|
||||
{
|
||||
FadeOut(250);
|
||||
Content.ScaleTo(0.7f, 750, EasingTypes.InQuint);
|
||||
|
||||
dimLevel.ValueChanged -= dimChanged;
|
||||
Background?.FadeTo(1f, 200);
|
||||
return base.OnExiting(next);
|
||||
|
@ -80,6 +80,8 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
Schedule(() =>
|
||||
{
|
||||
if (!IsCurrentScreen) return;
|
||||
|
||||
if (!Push(player))
|
||||
Exit();
|
||||
});
|
||||
@ -89,6 +91,12 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
Content.ScaleTo(0.7f, 150, EasingTypes.InQuint);
|
||||
FadeOut(150);
|
||||
|
||||
//OsuScreens are currently never finalised due to the Bindable<Beatmap> bindings.
|
||||
//can be removed once we solve that one.
|
||||
if (player != null && player.LoadState != LoadState.Alive)
|
||||
player.Dispose();
|
||||
|
||||
return base.OnExiting(next);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user