Возможный фикс утечки памяти в меню аплинка с музыкой (#3804)

This commit is contained in:
ThereDrD 2026-01-28 08:25:15 +03:00 committed by GitHub
parent 8725604e5d
commit 91b97dbd6b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 3 deletions

View file

@ -61,7 +61,7 @@ public sealed class TapePlayerBoundUserInterface : BoundUserInterface
if (_entityManager.TryGetComponent<MusicTapeComponent>(tapePlayer.InsertedTape, out var musicTapeComponent))
{
var audio = EntMan.System<AudioSystem>();
var length = audio.GetAudioLength(audio.GetSound(musicTapeComponent.Sound));
var length = audio.GetAudioLength(audio.ResolveSound(musicTapeComponent.Sound));
_menu.SetSelectedSong(musicTapeComponent.SongName, (float) length.TotalSeconds);
}
else
@ -104,7 +104,7 @@ public sealed class TapePlayerBoundUserInterface : BoundUserInterface
return;
_menu.OnClose -= Close;
_menu.Dispose();
_menu.Orphan();
_menu = null;
}
}

View file

@ -46,6 +46,9 @@ namespace Content.Client._Sunrise.TapePlayer
private void OnTapePlayerAfterState(Entity<TapePlayerComponent> ent, ref AfterAutoHandleStateEvent args)
{
if (IsClientSide(ent))
return;
if (!_uiSystem.TryGetOpenUi<TapePlayerBoundUserInterface>(ent.Owner, TapePlayerUiKey.Key, out var bui))
return;

View file

@ -6,7 +6,7 @@ namespace Content.Shared._Sunrise.TapePlayer
[RegisterComponent, NetworkedComponent]
public sealed partial class MusicTapeComponent : Component
{
[DataField(customTypeSerializer: typeof(SoundSpecifierTypeSerializer), required: true)]
[DataField(required: true)]
public SoundSpecifier Sound;
[DataField]