Merge pull request #398 from peppy/fix-memory-leak

Fix memory leak from Player's InputManager.
This commit is contained in:
Thomas Müller 2017-02-25 09:08:23 +01:00 committed by GitHub
commit 6a2d1f92e5
3 changed files with 21 additions and 9 deletions

View File

@ -59,7 +59,7 @@ public void TestImportOverIPC()
if (!importer.ImportAsync(osz_path).Wait(1000))
Assert.Fail(@"IPC took too long to send");
ensureLoaded(osu, 10000);
ensureLoaded(osu);
}
}
@ -77,23 +77,23 @@ private OsuGameBase loadOsu(GameHost host)
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 @@ private void ensureLoaded(OsuGameBase osu, int timeout = 100)
{
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));

View File

@ -312,6 +312,9 @@ protected override bool OnExiting(Screen next)
}
else
{
FadeOut(250);
Content.ScaleTo(0.7f, 750, EasingTypes.InQuint);
dimLevel.ValueChanged -= dimChanged;
Background?.FadeTo(1f, 200);
return base.OnExiting(next);

View File

@ -80,6 +80,8 @@ protected override void OnEntering(Screen last)
Schedule(() =>
{
if (!IsCurrentScreen) return;
if (!Push(player))
Exit();
});
@ -89,6 +91,12 @@ protected override bool OnExiting(Screen next)
{
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);
}