From: jpbruyere Date: Fri, 21 Aug 2015 14:13:30 +0000 (+0200) Subject: Avoid some null exception while layouting when parent not already set, and raise... X-Git-Tag: 0.2~68 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=7f3b87047828b7d8a250ec3e696361538fa7a3f4;p=jp%2Fcrow.git Avoid some null exception while layouting when parent not already set, and raise exception when goml file not found --- diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 4e13b34d..457a6016 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -379,7 +379,8 @@ namespace go /// public virtual void RegisterForRedraw () { - TopContainer.gobjsToRedraw.Add (this); + if (TopContainer != null) + TopContainer.gobjsToRedraw.Add (this); } /// @@ -457,6 +458,9 @@ namespace go /// trigger dependant sizing component update protected virtual void OnLayoutChanges(LayoutingType layoutType) { + if (Parent==null) + return; + switch (layoutType) { case LayoutingType.Width: if (Parent.getBounds ().Width < 0) diff --git a/src/Interface.cs b/src/Interface.cs index 2fe25c60..3e0f8771 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -89,6 +89,9 @@ namespace go string root = "Object"; Stream stream = GetStreamFromPath (path); + if (stream == null) + throw new FileNotFoundException ("GOML file not found", path); + using (XmlReader reader = XmlReader.Create (stream)) { while (reader.Read()) { // first element is the root element