1- // COPYRIGHT 2009, 2010, 2011, 2012, 2013 by the Open Rails project.
1+ // COPYRIGHT 2021 by the Open Rails project.
22//
33// This file is part of Open Rails.
44//
3636using System . Security . Cryptography ;
3737using System . Text ;
3838using System . Text . RegularExpressions ;
39- using System . Threading ;
4039using System . Windows . Forms ;
4140
4241namespace Orts . Viewer3D . Processes
@@ -79,6 +78,14 @@ public GameStateRunActivity(string[] args)
7978 Arguments = args ;
8079 }
8180
81+ internal override void Dispose ( )
82+ {
83+ Loading . Dispose ( ) ;
84+ LoadingScreen . Dispose ( ) ;
85+ LoadingBar . Dispose ( ) ;
86+ base . Dispose ( ) ;
87+ }
88+
8289 internal override void Update ( RenderFrame frame , double totalRealSeconds )
8390 {
8491 UpdateLoading ( ) ;
@@ -1240,12 +1247,11 @@ long GetProcessBytesLoaded()
12401247 return 0 ;
12411248 }
12421249
1243- class LoadingPrimitive : RenderPrimitive
1250+ class LoadingPrimitive : RenderPrimitive , IDisposable
12441251 {
12451252 public readonly LoadingMaterial Material ;
12461253 readonly VertexBuffer VertexBuffer ;
12471254
1248- [ System . Diagnostics . CodeAnalysis . SuppressMessage ( "Microsoft.Usage" , "CA2214:DoNotCallOverridableMethodsInConstructors" ) ]
12491255 public LoadingPrimitive ( Game game )
12501256 {
12511257 Material = GetMaterial ( game ) ;
@@ -1269,6 +1275,11 @@ virtual protected VertexPositionTexture[] GetVerticies(Game game)
12691275 new VertexPositionTexture ( new Vector3 ( + dd - 0.5f , - dd + 0.5f , - 3 ) , new Vector2 ( 1 , 1 ) ) ,
12701276 } ;
12711277 }
1278+
1279+ public void Dispose ( )
1280+ {
1281+ Material . Dispose ( ) ;
1282+ }
12721283
12731284 public override void Draw ( GraphicsDevice graphicsDevice )
12741285 {
@@ -1343,19 +1354,23 @@ protected override VertexPositionTexture[] GetVerticies(Game game)
13431354 }
13441355 }
13451356
1346- class LoadingMaterial : Material
1357+ class LoadingMaterial : Material , IDisposable
13471358 {
13481359 public readonly LoadingShader Shader ;
13491360 public readonly Texture2D Texture ;
13501361
1351- [ System . Diagnostics . CodeAnalysis . SuppressMessage ( "Microsoft.Usage" , "CA2214:DoNotCallOverridableMethodsInConstructors" ) ]
13521362 public LoadingMaterial ( Game game )
13531363 : base ( null , null )
13541364 {
13551365 Shader = new LoadingShader ( game . RenderProcess . GraphicsDevice ) ;
13561366 Texture = GetTexture ( game ) ;
13571367 }
13581368
1369+ public void Dispose ( )
1370+ {
1371+ Texture . Dispose ( ) ;
1372+ }
1373+
13591374 virtual protected Texture2D GetTexture ( Game game )
13601375 {
13611376 return SharedTextureManager . Get ( game . RenderProcess . GraphicsDevice , Path . Combine ( game . ContentPath , "Loading.png" ) ) ;
0 commit comments