From f145745b25eae8f77425437765918f85b30300bc Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 7 Sep 2015 13:07:59 +0200 Subject: [PATCH] Destroy context after OnHandleDestroyed to allow cleanup --- Source/GLControl/GLControl.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/GLControl/GLControl.cs b/Source/GLControl/GLControl.cs index ecf5e94..2bb7497 100644 --- a/Source/GLControl/GLControl.cs +++ b/Source/GLControl/GLControl.cs @@ -226,6 +226,10 @@ namespace OpenTK /// Not used. protected override void OnHandleDestroyed(EventArgs e) { + // Ensure that context is still alive when passing to events + // => This allows to perform cleanup operations in OnHandleDestroyed handlers + base.OnHandleDestroyed(e); + if (context != null) { context.Dispose(); @@ -238,7 +242,6 @@ namespace OpenTK implementation = null; } - base.OnHandleDestroyed(e); } /// -- 2.7.4