iliak's picture

Unhandled exception in GlControl possible bug in rev 2207

Project:The Open Toolkit library
Version:0.9.9-2b
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

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()
        {
            Context.MakeCurrent(Implementation.WindowInfo);
        }

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


Comments

Comment viewing options

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

#1

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

#2

Status:open» confirmed

(Forgot to change the status)

iliak's picture

#3

I would to something like this :

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

#4

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

#5

Looks fine...

the Fiddler's picture

#6

Status:in progress (review)» fixed

Thanks, marking as fixed.

the Fiddler's picture

#7

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

Closing issues fixed in 0.9.9-2.