Setting VSync mode should not force control creation. Fixes issue [#1071]: "Not firing Load event for GLControl."

This commit is contained in:
the_fiddler 2009-09-18 15:46:00 +00:00
parent 3170c7aa0a
commit a122fcd239

View file

@ -50,6 +50,7 @@ namespace OpenTK
GraphicsMode format;
int major, minor;
GraphicsContextFlags flags;
bool? initial_vsync_value;
#region --- Constructors ---
@ -141,6 +142,13 @@ namespace OpenTK
if (!DesignMode)
((IGraphicsContextInternal)Context).LoadAll();
// Deferred setting of vsync mode. See VSync property for more information.
if (initial_vsync_value.HasValue)
{
Context.VSync = initial_vsync_value.Value;
initial_vsync_value = null;
}
base.OnHandleCreated(e);
}
@ -294,11 +302,24 @@ namespace OpenTK
{
get
{
if (!IsHandleCreated)
return false;
ValidateState();
return Context.VSync;
}
set
{
// The winforms designer sets this to false by default which forces control creation.
// However, events are typically connected after the VSync = false assignment, which
// can lead to "event xyz is not fired" issues.
// Work around this issue by deferring VSync mode setting to the HandleCreated event.
if (!IsHandleCreated)
{
initial_vsync_value = value;
return;
}
ValidateState();
Context.VSync = value;
}