From cb9c992abfc5c003b020f97f1384bc7c0e346534 Mon Sep 17 00:00:00 2001 From: tobigun Date: Mon, 3 May 2010 16:36:52 +0000 Subject: - Free Statics/Buttons/Texts if a screen is destroyed (Textures used by those components are not unloaded yet) - Use Free() instead of Destroy() as it checks for nil by default git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2334 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/menu/UMenu.pas | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'src/menu') diff --git a/src/menu/UMenu.pas b/src/menu/UMenu.pas index dd4f257e..6bceef62 100644 --- a/src/menu/UMenu.pas +++ b/src/menu/UMenu.pas @@ -206,11 +206,22 @@ uses UMenuBackgroundFade; destructor TMenu.Destroy; +var + I: integer; begin - if (Background <> nil) then - begin - Background.Destroy; - end; + for I := 0 to High(Button) do + Button[I].Free; + for I := 0 to High(ButtonCollection) do + ButtonCollection[I].Free; + for I := 0 to High(SelectsS) do + SelectsS[I].Free; + for I := 0 to High(Text) do + Text[I].Free; + for I := 0 to High(Statics) do + Statics[I].Free; + + Background.Free; + //Log.LogError('Unloaded Succesful: ' + ClassName); inherited; end; @@ -379,11 +390,7 @@ procedure TMenu.AddBackground(ThemedSettings: TThemeBackground); end; begin - if (Background <> nil) then - begin - Background.Destroy; - Background := nil; - end; + FreeAndNil(Background); case ThemedSettings.BGType of bgtAuto: begin //Automaticly choose one out of BGT_Texture, BGT_Video or BGT_Color -- cgit v1.2.3