Browse Source

Updates sample/tests projects for strict disposal

Game is now quite strict about not being used after it has been
Disposed, so it was necessary to update all the tests and samples that
had using-blocks around asynchronous Game.Run calls, or which didn't
keep a strong reference to the Game object after creation.
Christopher Chambers 13 years ago
parent
commit
365e81e638

+ 4 - 4
Samples/MacOS/Primitives/Program.cs

@@ -22,12 +22,12 @@ namespace PrimitivesSample
 	
 	
 		class AppDelegate : MonoMac.AppKit.NSApplicationDelegate
 		class AppDelegate : MonoMac.AppKit.NSApplicationDelegate
 		{
 		{
-		
+
+            PrimitivesSampleGame game;
 			public override void FinishedLaunching (MonoMac.Foundation.NSObject notification)
 			public override void FinishedLaunching (MonoMac.Foundation.NSObject notification)
 			{
 			{
-				using (PrimitivesSampleGame game = new PrimitivesSampleGame()) {
-					game.Run ();
-				}
+				game = new PrimitivesSampleGame();
+				game.Run();
 			}
 			}
 		
 		
 			public override bool ApplicationShouldTerminateAfterLastWindowClosed (MonoMac.AppKit.NSApplication sender)
 			public override bool ApplicationShouldTerminateAfterLastWindowClosed (MonoMac.AppKit.NSApplication sender)

BIN
Samples/MacOS/StateObjectWindows/Program.cs


+ 2 - 1
Samples/iOS/Aiming/Main.cs

@@ -12,10 +12,11 @@ namespace Aiming
     [Register("AppDelegate")]
     [Register("AppDelegate")]
     class Program : UIApplicationDelegate
     class Program : UIApplicationDelegate
     {
     {
+        AimingGame game;
         public override void FinishedLaunching(UIApplication app)
         public override void FinishedLaunching(UIApplication app)
         {
         {
             // Fun begins..
             // Fun begins..
-            AimingGame game = new AimingGame();
+            game = new AimingGame();
             game.Run();
             game.Run();
         }
         }
 
 

+ 2 - 1
Samples/iOS/ChaseAndEvade/Main.cs

@@ -12,10 +12,11 @@ namespace ChaseAndEvade
     [Register("AppDelegate")]
     [Register("AppDelegate")]
     class Program : UIApplicationDelegate
     class Program : UIApplicationDelegate
     {
     {
+        ChaseAndEvadeGame game;
         public override void FinishedLaunching(UIApplication app)
         public override void FinishedLaunching(UIApplication app)
         {
         {
             // Fun begins..
             // Fun begins..
-            ChaseAndEvadeGame game = new ChaseAndEvadeGame();
+            game = new ChaseAndEvadeGame();
             game.Run();
             game.Run();
         }
         }
 
 

+ 2 - 1
Samples/iOS/GameStateManagement/Program.cs

@@ -16,10 +16,11 @@ namespace Microsoft.Xna.Samples.GameStateManagement
     [Register("AppDelegate")]
     [Register("AppDelegate")]
     class Program : UIApplicationDelegate
     class Program : UIApplicationDelegate
     {
     {
+        GameStateManagementGame game;
         public override void FinishedLaunching(UIApplication app)
         public override void FinishedLaunching(UIApplication app)
         {
         {
             // Fun begins..
             // Fun begins..
-            GameStateManagementGame game = new GameStateManagementGame();
+            game = new GameStateManagementGame();
             game.Run();
             game.Run();
         }
         }
 
 

+ 2 - 2
Samples/iOS/MonoGame.Samples.Primitives/Program.cs

@@ -8,11 +8,11 @@ namespace PrimitivesSample
 	[Register ("AppDelegate")]
 	[Register ("AppDelegate")]
 	class Program : UIApplicationDelegate 
 	class Program : UIApplicationDelegate 
 	{
 	{
-
+        PrimitivesSampleGame game;
 		public override void FinishedLaunching (UIApplication app)
 		public override void FinishedLaunching (UIApplication app)
 		{
 		{
 			// Fun begins..
 			// Fun begins..
-			PrimitivesSampleGame game = new PrimitivesSampleGame();
+			game = new PrimitivesSampleGame();
 			game.Run ();
 			game.Run ();
 		}
 		}
 
 

+ 2 - 1
Samples/iOS/MultiTouch/Program.cs

@@ -11,10 +11,11 @@ namespace Microsoft.Xna.Samples.MultiTouch
     [Register("AppDelegate")]
     [Register("AppDelegate")]
     class Program : UIApplicationDelegate
     class Program : UIApplicationDelegate
     {
     {
+        Game1 game;
         public override void FinishedLaunching(UIApplication app)
         public override void FinishedLaunching(UIApplication app)
         {
         {
             // Fun begins..
             // Fun begins..
-            Game1 game = new Game1();
+            game = new Game1();
             game.Run();
             game.Run();
         }
         }
 
 

+ 2 - 1
Samples/iOS/ParticleSample/Main.cs

@@ -12,10 +12,11 @@ namespace ParticleSample
     [Register("AppDelegate")]
     [Register("AppDelegate")]
     class Program : UIApplicationDelegate
     class Program : UIApplicationDelegate
     {
     {
+        ParticleSampleGame game;
         public override void FinishedLaunching(UIApplication app)
         public override void FinishedLaunching(UIApplication app)
         {
         {
             // Fun begins..
             // Fun begins..
-            ParticleSampleGame game = new ParticleSampleGame();
+            game = new ParticleSampleGame();
             game.Run();
             game.Run();
         }
         }
 
 

+ 2 - 2
Samples/iOS/PerPixelCollision/Program.cs

@@ -8,11 +8,11 @@ namespace PerPixelCollision
 	[Register ("AppDelegate")]
 	[Register ("AppDelegate")]
 	class Program : UIApplicationDelegate 
 	class Program : UIApplicationDelegate 
 	{
 	{
-
+        PerPixelCollisionGame game;
 		public override void FinishedLaunching (UIApplication app)
 		public override void FinishedLaunching (UIApplication app)
 		{
 		{
 			// Fun begins..
 			// Fun begins..
-			PerPixelCollisionGame game = new PerPixelCollisionGame();
+			game = new PerPixelCollisionGame();
 			game.Run ();
 			game.Run ();
 		}
 		}
 
 

+ 2 - 2
Samples/iOS/RectangleCollision/Program.cs

@@ -8,11 +8,11 @@ namespace RectangleCollision
 	[Register ("AppDelegate")]
 	[Register ("AppDelegate")]
 	class Program : UIApplicationDelegate 
 	class Program : UIApplicationDelegate 
 	{
 	{
-
+        RectangleCollisionGame game;
 		public override void FinishedLaunching (UIApplication app)
 		public override void FinishedLaunching (UIApplication app)
 		{
 		{
 			// Fun begins..
 			// Fun begins..
-			RectangleCollisionGame game = new RectangleCollisionGame();
+			game = new RectangleCollisionGame();
 			game.Run();
 			game.Run();
 		}
 		}
 
 

+ 2 - 1
Samples/iOS/RenderTarget2D/Main.cs

@@ -10,10 +10,11 @@ namespace RenderTarget2DSample
     [Register("AppDelegate")]
     [Register("AppDelegate")]
     class Program : UIApplicationDelegate
     class Program : UIApplicationDelegate
     {
     {
+        Game1 game;
         public override void FinishedLaunching(UIApplication app)
         public override void FinishedLaunching(UIApplication app)
         {
         {
             // Fun begins..
             // Fun begins..
-            Game1 game = new Game1();
+            game = new Game1();
             game.Run();
             game.Run();
         }
         }
 
 

+ 2 - 1
Samples/iOS/TouchGesture/Program.cs

@@ -20,10 +20,11 @@ namespace TouchGestureSample
     [Register("AppDelegate")]
     [Register("AppDelegate")]
     class Program : UIApplicationDelegate
     class Program : UIApplicationDelegate
     {
     {
+        Game1 game;
         public override void FinishedLaunching(UIApplication app)
         public override void FinishedLaunching(UIApplication app)
         {
         {
             // Fun begins..
             // Fun begins..
-            Game1 game = new Game1();
+            game = new Game1();
             game.Run();
             game.Run();
         }
         }
 
 

+ 2 - 2
Samples/iOS/TransformedCollision/Program.cs

@@ -8,11 +8,11 @@ namespace TransformedCollision
 	[Register ("AppDelegate")]
 	[Register ("AppDelegate")]
 	class Program : UIApplicationDelegate 
 	class Program : UIApplicationDelegate 
 	{
 	{
-
+        TransformedCollisionGame game;
 		public override void FinishedLaunching (UIApplication app)
 		public override void FinishedLaunching (UIApplication app)
 		{
 		{
 			// Fun begins..
 			// Fun begins..
-			TransformedCollisionGame game = new TransformedCollisionGame();
+			game = new TransformedCollisionGame();
 			game.Run ();
 			game.Run ();
 		}
 		}
 
 

+ 2 - 1
Samples/iOS/Waypoint/Main.cs

@@ -12,10 +12,11 @@ namespace Waypoint
     [Register("AppDelegate")]
     [Register("AppDelegate")]
     class Program : UIApplicationDelegate
     class Program : UIApplicationDelegate
     {
     {
+        WaypointSample game;
         public override void FinishedLaunching(UIApplication app)
         public override void FinishedLaunching(UIApplication app)
         {
         {
             // Fun begins..
             // Fun begins..
-            WaypointSample game = new WaypointSample();
+            game = new WaypointSample();
             game.Run();
             game.Run();
         }
         }
 
 

+ 3 - 3
StarterKits/MacOS/VectorRumble/Program.cs

@@ -18,11 +18,11 @@ namespace VectorRumble
 	
 	
 	class AppDelegate : NSApplicationDelegate
 	class AppDelegate : NSApplicationDelegate
 	{
 	{
+        VectorRumbleGame game;
 		public override void FinishedLaunching (MonoMac.Foundation.NSObject notification)
 		public override void FinishedLaunching (MonoMac.Foundation.NSObject notification)
 		{			
 		{			
-			using (VectorRumbleGame game = new VectorRumbleGame()) {
-				game.Run ();
-			}
+			game = new VectorRumbleGame();
+			game.Run();
 		}
 		}
 		
 		
 		public override bool ApplicationShouldTerminateAfterLastWindowClosed (NSApplication sender)
 		public override bool ApplicationShouldTerminateAfterLastWindowClosed (NSApplication sender)

+ 3 - 4
Tests/MacOS/GamePadTest/Program.cs

@@ -24,12 +24,11 @@ namespace GamePadTest
 	
 	
 		class AppDelegate : MonoMac.AppKit.NSApplicationDelegate
 		class AppDelegate : MonoMac.AppKit.NSApplicationDelegate
 		{
 		{
-		
+
 			public override void FinishedLaunching (MonoMac.Foundation.NSObject notification)
 			public override void FinishedLaunching (MonoMac.Foundation.NSObject notification)
 			{
 			{
-				using (game = new Game1()) {
-					game.Run ();
-				}
+				game = new Game1();
+				game.Run();
 			}
 			}
 		
 		
 			public override bool ApplicationShouldTerminateAfterLastWindowClosed (MonoMac.AppKit.NSApplication sender)
 			public override bool ApplicationShouldTerminateAfterLastWindowClosed (MonoMac.AppKit.NSApplication sender)

+ 4 - 4
Tests/MacOS/MouseGetStateAndIsMouseVisibleTester/MouseGetStateAndIsMouseVisibleTester/Program.cs

@@ -38,12 +38,12 @@ namespace MouseGetStateAndIsMouseVisibleTester
 	
 	
 	class AppDelegate : MonoMac.AppKit.NSApplicationDelegate
 	class AppDelegate : MonoMac.AppKit.NSApplicationDelegate
 	{
 	{
-		
+
+        Game1 game;
 		public override void FinishedLaunching (MonoMac.Foundation.NSObject notification)
 		public override void FinishedLaunching (MonoMac.Foundation.NSObject notification)
 		{
 		{
-			using (Game1 game = new Game1()) {
-				game.Run ();
-			}
+			Game1 game = new Game1();
+			game.Run();
 		}
 		}
 		
 		
 		public override bool ApplicationShouldTerminateAfterLastWindowClosed (MonoMac.AppKit.NSApplication sender)
 		public override bool ApplicationShouldTerminateAfterLastWindowClosed (MonoMac.AppKit.NSApplication sender)

+ 3 - 4
Tests/MacOS/PrimitivesTest/Program.cs

@@ -24,12 +24,11 @@ namespace DrawUserPrimitivesWindows
 	
 	
 		class AppDelegate : MonoMac.AppKit.NSApplicationDelegate
 		class AppDelegate : MonoMac.AppKit.NSApplicationDelegate
 		{
 		{
-		
+            Game1 game;
 			public override void FinishedLaunching (MonoMac.Foundation.NSObject notification)
 			public override void FinishedLaunching (MonoMac.Foundation.NSObject notification)
 			{
 			{
-				using (game = new Game1()) {
-					game.Run ();
-				}
+				game = new Game1();
+				game.Run();
 			}
 			}
 		
 		
 			public override bool ApplicationShouldTerminateAfterLastWindowClosed (MonoMac.AppKit.NSApplication sender)
 			public override bool ApplicationShouldTerminateAfterLastWindowClosed (MonoMac.AppKit.NSApplication sender)

+ 2 - 4
Tests/MacOS/SoundTest/SoundTest/Program.cs

@@ -42,12 +42,10 @@ namespace SoundTest
     class AppDelegate : NSApplicationDelegate
     class AppDelegate : NSApplicationDelegate
     {
     {
 		Game1 game;
 		Game1 game;
- 
         public override void FinishedLaunching (MonoMac.Foundation.NSObject notification)
         public override void FinishedLaunching (MonoMac.Foundation.NSObject notification)
         {
         {
-            using (game  = new Game1()) {
-                game.Run ();
-            }
+            game = new Game1();
+            game.Run ();
         }
         }
  
  
         public override bool ApplicationShouldTerminateAfterLastWindowClosed (NSApplication sender)
         public override bool ApplicationShouldTerminateAfterLastWindowClosed (NSApplication sender)

+ 2 - 3
Tests/MacOS/SoundTest2/SoundTest2_MacOs/Program.cs

@@ -45,9 +45,8 @@ namespace SoundTest
  
  
         public override void FinishedLaunching (MonoMac.Foundation.NSObject notification)
         public override void FinishedLaunching (MonoMac.Foundation.NSObject notification)
         {
         {
-            using (game  = new Game1()) {
-                game.Run ();
-            }
+            game = new Game1();
+            game.Run();
         }
         }
  
  
         public override bool ApplicationShouldTerminateAfterLastWindowClosed (NSApplication sender)
         public override bool ApplicationShouldTerminateAfterLastWindowClosed (NSApplication sender)

+ 3 - 4
Tests/MacOS/TestDataSetAndGet/Program.cs

@@ -36,12 +36,11 @@ namespace TestDataSetAndGet
 	
 	
 	class AppDelegate : NSApplicationDelegate
 	class AppDelegate : NSApplicationDelegate
 	{
 	{
-		
+		PerPixelCollisionGame game;
 		public override void FinishedLaunching (MonoMac.Foundation.NSObject notification)
 		public override void FinishedLaunching (MonoMac.Foundation.NSObject notification)
 		{
 		{
-			using (PerPixelCollisionGame game = new PerPixelCollisionGame()) {
-				game.Run ();
-			}
+			game = new PerPixelCollisionGame();
+			game.Run();
 		}
 		}
 		
 		
 		public override bool ApplicationShouldTerminateAfterLastWindowClosed (NSApplication sender)
 		public override bool ApplicationShouldTerminateAfterLastWindowClosed (NSApplication sender)

+ 2 - 3
Tests/MacOS/TextureScaleColorTest/Program.cs

@@ -24,9 +24,8 @@ namespace MonoTest
  
  
         public override void FinishedLaunching (MonoMac.Foundation.NSObject notification)
         public override void FinishedLaunching (MonoMac.Foundation.NSObject notification)
         {
         {
-            using (game  = new Game1()) {
-                game.Run ();
-            }
+            game = new Game1();
+            game.Run ();
         }
         }
  
  
         public override bool ApplicationShouldTerminateAfterLastWindowClosed (NSApplication sender)
         public override bool ApplicationShouldTerminateAfterLastWindowClosed (NSApplication sender)