mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-11 19:35:38 +00:00
Added fix for issue [#2506]: "GLControl inside a user control crashes during design time".
This commit is contained in:
parent
46d7abc467
commit
967eb64ed6
|
@ -56,6 +56,10 @@ namespace OpenTK
|
||||||
// the premature Resize event and raise it as soon as the handle
|
// the premature Resize event and raise it as soon as the handle
|
||||||
// is ready.
|
// is ready.
|
||||||
bool resize_event_suppressed;
|
bool resize_event_suppressed;
|
||||||
|
// Indicates whether the control is in design mode. Due to issues
|
||||||
|
// wiith the DesignMode property and nested controls,we need to
|
||||||
|
// evaluate this in the constructor.
|
||||||
|
readonly bool design_mode;
|
||||||
|
|
||||||
#region --- Constructors ---
|
#region --- Constructors ---
|
||||||
|
|
||||||
|
@ -96,6 +100,13 @@ namespace OpenTK
|
||||||
this.minor = minor;
|
this.minor = minor;
|
||||||
this.flags = flags;
|
this.flags = flags;
|
||||||
|
|
||||||
|
// Note: the DesignMode property may be incorrect when nesting controls.
|
||||||
|
// We use LicenseManager.UsageMode as a workaround (this only works in
|
||||||
|
// the constructor).
|
||||||
|
design_mode =
|
||||||
|
DesignMode ||
|
||||||
|
LicenseManager.UsageMode == LicenseUsageMode.Designtime;
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +150,7 @@ namespace OpenTK
|
||||||
if (implementation != null)
|
if (implementation != null)
|
||||||
implementation.WindowInfo.Dispose();
|
implementation.WindowInfo.Dispose();
|
||||||
|
|
||||||
if (DesignMode)
|
if (design_mode)
|
||||||
implementation = new DummyGLControl();
|
implementation = new DummyGLControl();
|
||||||
else
|
else
|
||||||
implementation = new GLControlFactory().CreateGLControl(format, this);
|
implementation = new GLControlFactory().CreateGLControl(format, this);
|
||||||
|
@ -147,7 +158,7 @@ namespace OpenTK
|
||||||
context = implementation.CreateContext(major, minor, flags);
|
context = implementation.CreateContext(major, minor, flags);
|
||||||
MakeCurrent();
|
MakeCurrent();
|
||||||
|
|
||||||
if (!DesignMode)
|
if (!design_mode)
|
||||||
((IGraphicsContextInternal)Context).LoadAll();
|
((IGraphicsContextInternal)Context).LoadAll();
|
||||||
|
|
||||||
// Deferred setting of vsync mode. See VSync property for more information.
|
// Deferred setting of vsync mode. See VSync property for more information.
|
||||||
|
@ -193,7 +204,7 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
ValidateState();
|
ValidateState();
|
||||||
|
|
||||||
if (DesignMode)
|
if (design_mode)
|
||||||
e.Graphics.Clear(BackColor);
|
e.Graphics.Clear(BackColor);
|
||||||
|
|
||||||
base.OnPaint(e);
|
base.OnPaint(e);
|
||||||
|
|
Loading…
Reference in a new issue