Browse files

Fix potential exception that I was ignoring.

This can happen, so we should handle it
  • Loading branch information...
1 parent 794d45f commit ba0180ed77342e0a9f2ccc6dbc4d29df145f0e99 Paul Kratt committed Feb 22, 2014
Showing with 7 additions and 4 deletions.
  1. +7 −4 Source/GLControl/CarbonGLControl.cs
View
11 Source/GLControl/CarbonGLControl.cs
@@ -54,10 +54,13 @@ internal CarbonGLControl(GraphicsMode mode, Control owner)
}
private int GetYOffset(){
- System.Drawing.Point offset = control.PointToScreen(control.Location);
- System.Drawing.Point windowOffset = control.TopLevelControl.PointToScreen(System.Drawing.Point.Empty);
- int relativeY = offset.Y-windowOffset.Y; //control.TopLevelControl.Location.Y is not the same as windowOffset.Y for some reason.
- return control.TopLevelControl.ClientSize.Height - control.Bottom - relativeY;
+ if (control.TopLevelControl != null) {
+ System.Drawing.Point offset = control.PointToScreen (control.Location);
+ System.Drawing.Point windowOffset = control.TopLevelControl.PointToScreen (System.Drawing.Point.Empty);
+ int relativeY = offset.Y - windowOffset.Y; //control.TopLevelControl.Location.Y is not the same as windowOffset.Y for some reason.
+ return control.TopLevelControl.ClientSize.Height - control.Bottom - relativeY;
+ }
+ return control.Location.Y;
}
#region IGLControl Members

0 comments on commit ba0180e

Please sign in to comment.