diff --git a/Launcher2/Gui/PlatformDrawer.cs b/Launcher2/Gui/PlatformDrawer.cs index a619e7de5..0a9f47207 100644 --- a/Launcher2/Gui/PlatformDrawer.cs +++ b/Launcher2/Gui/PlatformDrawer.cs @@ -42,7 +42,6 @@ namespace Launcher2 { IntPtr windowPort; public override void Init( IWindowInfo info ) { windowPort = OSX.API.GetWindowPort( info.WinHandle ); - } public override void Resize( IWindowInfo info ) { diff --git a/OpenTK/Debug.cs b/OpenTK/Debug.cs index 4cd16bcfa..54a97edd8 100644 --- a/OpenTK/Debug.cs +++ b/OpenTK/Debug.cs @@ -6,15 +6,24 @@ namespace OpenTK { public static class Debug { public static void Print( string text ) { - Console.WriteLine( text ); + try { + Console.WriteLine( text ); + } catch( NotSupportedException ) { + } // raised by Mono sometimes when trying to write to console from the finalizer thread. } public static void Print( object arg ) { - Console.WriteLine( arg ); + try { + Console.WriteLine( arg ); + } catch( NotSupportedException ) { + } } public static void Print( string text, params object[] args ) { - Console.WriteLine( text, args ); + try { + Console.WriteLine( text, args ); + } catch( NotSupportedException ) { + } } } } diff --git a/OpenTK/Platform/MacOS/CarbonGLNative.cs b/OpenTK/Platform/MacOS/CarbonGLNative.cs index bb3a825a6..1f92e5fe3 100644 --- a/OpenTK/Platform/MacOS/CarbonGLNative.cs +++ b/OpenTK/Platform/MacOS/CarbonGLNative.cs @@ -83,30 +83,23 @@ namespace OpenTK.Platform.MacOS GC.SuppressFinalize(this); } - protected virtual void Dispose(bool disposing) - { + protected virtual void Dispose(bool disposing) { if (mIsDisposed) return; Debug.Print("Disposing of CarbonGLNative window."); - API.DisposeWindow(window.WindowRef); - mIsDisposed = true; mExists = false; - if (disposing) - { + if (disposing) { mWindows.Remove(window.WindowRef); - - window.Dispose(); window = null; } DisposeUPP(); } - ~CarbonGLNative() - { + ~CarbonGLNative() { Dispose(false); } @@ -134,7 +127,7 @@ namespace OpenTK.Platform.MacOS Debug.Print( "Created window " + windowRef ); API.SetWindowTitle(windowRef, title); - window = new CarbonWindowInfo(windowRef, true); + window = new CarbonWindowInfo(windowRef); SetLocation(r.X, r.Y); SetSize(r.Width, r.Height); mWindows.Add(windowRef, new WeakReference(this)); @@ -769,7 +762,6 @@ namespace OpenTK.Platform.MacOS return; OnClosed(); - Dispose(); } diff --git a/OpenTK/Platform/MacOS/CarbonWindowInfo.cs b/OpenTK/Platform/MacOS/CarbonWindowInfo.cs index 02dcb7393..2d2da62b2 100644 --- a/OpenTK/Platform/MacOS/CarbonWindowInfo.cs +++ b/OpenTK/Platform/MacOS/CarbonWindowInfo.cs @@ -26,86 +26,32 @@ #endregion using System; -using System.Collections.Generic; -using System.Text; -namespace OpenTK.Platform.MacOS -{ +namespace OpenTK.Platform.MacOS { + /// \internal - /// - /// Describes a Carbon window. - /// - sealed class CarbonWindowInfo : IWindowInfo - { - IntPtr windowRef; - bool ownHandle = false; - bool disposed = false; + /// Describes a Carbon window. + sealed class CarbonWindowInfo : IWindowInfo { + + public IntPtr WindowRef; internal bool goFullScreenHack = false; internal bool goWindowedHack = false; - #region Constructors - - /// - /// Constructs a new instance with the specified parameters. - /// - /// A valid Carbon window reference. - /// - public CarbonWindowInfo(IntPtr windowRef, bool ownHandle) - { - this.windowRef = windowRef; - this.ownHandle = ownHandle; - } - - #endregion - - #region Public Members - - /// - /// Gets the window reference for this instance. - /// - internal IntPtr WindowRef - { - get { return this.windowRef; } + public CarbonWindowInfo(IntPtr windowRef) { + WindowRef = windowRef; } /// Returns a System.String that represents the current window. /// A System.String that represents the current window. - public override string ToString() - { + public override string ToString() { return String.Format("MacOS.CarbonWindowInfo: Handle {0}", WindowRef); } - - #endregion - // TODO: I have no idea if this is right. public IntPtr WinHandle { - get { return windowRef; } + get { return WindowRef; } } - #region IDisposable Members - public void Dispose() { - Dispose(true); } - - void Dispose(bool disposing) { - if (disposed) - return; - - if (ownHandle) - { - Debug.Print("Disposing window {0}.", windowRef); - Carbon.API.DisposeWindow(this.windowRef); - windowRef = IntPtr.Zero; - } - - disposed = true; - } - - ~CarbonWindowInfo() { - Dispose(false); - } - - #endregion } } \ No newline at end of file