iliak's picture

Unhandled exception in GlControl possible bug in rev 2207

Project:The Open Toolkit library
Category:bug report

In GLControl.cs line 209 :

        /// <summary>
        /// Makes the underlying this GLControl current in the calling thread.
        /// All OpenGL commands issued are hereafter interpreted by this GLControl.
        /// </summary>
        public void MakeCurrent()

No check is done if Context is null. Would be a good idea to handle the case where Context is invalid


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture


Public methods in GLControl fail to validate internal state. This should be fixed.

The question is whether we should throw an exception or (re-)initialize the GLControl silently. Windows.Forms tend to do the latter, for example when you try to access the Handle of an uninitialized Control.

Any ideas?

the Fiddler's picture


Status:open» confirmed

(Forgot to change the status)

iliak's picture


I would to something like this :

public void MakeCurrent()
	if (Context == null)
		Trace.WriteLine("No Context found !");
the Fiddler's picture


Status:confirmed» in progress (review)

I have committed a fix to rev. 2209 that checks whether the GLControl has been disposed (ObjectDisposedException) and tries to create/recreate the control if it doesn't have a handle/context respectively.

Can you please test that this hasn't introduced any bad side-effects on Windows? (Try running the various GLControl samples in Examples.exe -> OpenTK).

The documentation should also be updated to reflect the new behavior, will do that once you confirm that this hasn't introduced any regressions.

iliak's picture


Looks fine...

the Fiddler's picture


Status:in progress (review)» fixed

Thanks, marking as fixed.

the Fiddler's picture


Version:0.9.x-dev» 0.9.9-2b
Status:fixed» closed

Closing issues fixed in 0.9.9-2.