This project is read-only.

Crashing When Window Is Hidden


When drawing a single window and it is closed / hidden, Neoforce seems to crash with an object disposed exception.
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'RenderTarget2D'.
   at Microsoft.Xna.Framework.Helpers.CheckDisposed(Object obj, IntPtr pComPtr)
   at Microsoft.Xna.Framework.Graphics.GraphicsDevice.SetRenderTargets(RenderTargetBinding* pBindings, Int32 renderTargetCount)
   at Microsoft.Xna.Framework.Graphics.GraphicsDevice.SetRenderTarget(RenderTarget2D renderTarget)
   at TomShane.Neoforce.Controls.Manager.Draw(GameTime gameTime) in c:\Users\atom0s\Documents\Visual Studio 2012\Projects\Detox\Detox\NeoforceControls\Code\Manager.cs:line 1238
   at TomShane.Neoforce.Controls.Manager.BeginDraw(GameTime gameTime) in c:\Users\atom0s\Documents\Visual Studio 2012\Projects\Detox\Detox\NeoforceControls\Code\Manager.cs:line 1210
   at Detox.Hooks.Xna.PreDraw(GameTime gameTime) in c:\Users\atom0s\Documents\Visual Studio 2012\Projects\Detox\Detox\Detox\Hooks\Xna.cs:line 250
   at Terraria.Main.Draw(GameTime gameTime)
   at Microsoft.Xna.Framework.Game.DrawFrame()
   at Microsoft.Xna.Framework.Game.Tick()
   at Microsoft.Xna.Framework.Game.HostIdle(Object sender, EventArgs e)
   at Microsoft.Xna.Framework.GameHost.OnIdle()
   at Microsoft.Xna.Framework.WindowsGameHost.RunOneFrame()
   at Microsoft.Xna.Framework.WindowsGameHost.ApplicationIdle(Object sender, EventArgs e)
   at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FDoIdle(Int32 grfidlef)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)
   at Microsoft.Xna.Framework.WindowsGameHost.Run()
   at Microsoft.Xna.Framework.Game.RunGame(Boolean useBlockingRun)
   at Microsoft.Xna.Framework.Game.Run()
Steps to reproduce:
  1. Create a simple project.
  2. Create a simple window control. (And add to the manager.)
  3. Run application and close the Gui window.
  4. Resize the application window. (Maximize / Minimize / Resize all work to crash it.)
If a second window is being drawn it seems to not crash. But if all elements are hidden, it will.


atom0s wrote May 23, 2013 at 9:18 PM

A little more info on the window I created if it helps:
  • Custom control that inherits the Window object.
  • Contains the following controls:
  • 2x Group Boxes
  • 3x Stack Panels
  • 10x CheckBoxes
  • 1x TrackBar
  • 1x Label
One stack panel is added to the window itself. The other two are inside of the group boxes. (One each.)
Nine of the CheckBoxes are added to the first group boxes stack panel. The other is in the second group boxes stack panel with a label and the trackbar.

As long as the window is visible, I can resize the window fine without issue. No crashes at all and all the controls work as they should etc. As soon as the window is hidden either by closing it or setting the Visible status to false, any resizing to the window will crash the application with the above error.