From 7f3b87047828b7d8a250ec3e696361538fa7a3f4 Mon Sep 17 00:00:00 2001 From: jpbruyere Date: Fri, 21 Aug 2015 16:13:30 +0200 Subject: [PATCH] Avoid some null exception while layouting when parent not already set, and raise exception when goml file not found --- src/GraphicObjects/GraphicObject.cs | 6 +++++- src/Interface.cs | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) 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 -- 2.47.3