From a8ef6be6716f2b370b0522d8b3ae84f877e417ef Mon Sep 17 00:00:00 2001 From: Dani Date: Fri, 16 Apr 2021 11:18:18 +0100 Subject: [PATCH 1/2] Handling few invalid inputs --- GHUI/BuildHtmlUiComponent.cs | 6 ++++++ GHUI/Classes/WebView2Wrapper.cs | 2 ++ GHUI/HtmlUiComponent.cs | 5 +++++ GHUI/SettersDefineComponent.cs | 6 ++++++ GHUI/Web UI/createdInput.html | 2 +- 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/GHUI/BuildHtmlUiComponent.cs b/GHUI/BuildHtmlUiComponent.cs index 4f19c85..0456c8c 100644 --- a/GHUI/BuildHtmlUiComponent.cs +++ b/GHUI/BuildHtmlUiComponent.cs @@ -56,6 +56,12 @@ protected override void SolveInstance(IGH_DataAccess da) List jsScripts = new List(); if (!da.GetData(0, ref path)) return; + if(!System.IO.File.Exists(path)) + { + AddRuntimeMessage(GH_RuntimeMessageLevel.Error, $"File path: \"{path}\" not found on this computer"); + da.SetData(0, false); + return; + } if (!da.GetData(1, ref htmlString)) return; da.GetData(2, ref title); da.GetDataList(3, stylesheets); diff --git a/GHUI/Classes/WebView2Wrapper.cs b/GHUI/Classes/WebView2Wrapper.cs index a9ca47f..01b0b98 100644 --- a/GHUI/Classes/WebView2Wrapper.cs +++ b/GHUI/Classes/WebView2Wrapper.cs @@ -248,6 +248,8 @@ private void OnDocumentUpdated(object sender, DOM.DocumentUpdatedEventArgs args) /// public void SubscribeToHtmlChanged() { + if (!System.IO.Directory.Exists(Directory)) + throw new System.IO.DirectoryNotFoundException($"Can not find: \"{Directory}\" on this computer"); _watcher = new FileSystemWatcher(Directory) { NotifyFilter = NotifyFilters.LastAccess diff --git a/GHUI/HtmlUiComponent.cs b/GHUI/HtmlUiComponent.cs index 91ad4ff..66771f3 100644 --- a/GHUI/HtmlUiComponent.cs +++ b/GHUI/HtmlUiComponent.cs @@ -63,6 +63,11 @@ protected override void SolveInstance(IGH_DataAccess da) // get input if (!da.GetData(0, ref path)) return; + if (!System.IO.File.Exists(path)) + { + AddRuntimeMessage(GH_RuntimeMessageLevel.Error, $"File path: \"{path}\" not found on this computer"); + return; + } if (!da.GetData(1, ref show)) return; da.GetData(2, ref title); da.GetData(3, ref _height); diff --git a/GHUI/SettersDefineComponent.cs b/GHUI/SettersDefineComponent.cs index 873469f..dd4e8b0 100644 --- a/GHUI/SettersDefineComponent.cs +++ b/GHUI/SettersDefineComponent.cs @@ -39,6 +39,12 @@ protected override void SolveInstance(IGH_DataAccess da) if (!da.GetDataList(0, ids)) return; if (!da.GetDataList(1, vals)) return; + if(ids.Count != vals.Count) + { + AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Amount of IDs and Values must be equal"); + return; + } + //List setValueModels = // ids.Select((t, i) => new DomSetValueModelGoo() {id = t, value = vals[i]}).ToList(); diff --git a/GHUI/Web UI/createdInput.html b/GHUI/Web UI/createdInput.html index fc3e238..c7767a0 100644 --- a/GHUI/Web UI/createdInput.html +++ b/GHUI/Web UI/createdInput.html @@ -1 +1 @@ -
\ No newline at end of file +UIUI

HELLO THERE

\ No newline at end of file From 055776a6404e45453887e1c4af65735496fac5a0 Mon Sep 17 00:00:00 2001 From: DaniGA Date: Fri, 16 Apr 2021 11:26:08 +0100 Subject: [PATCH 2/2] back to original I had changed this file unintentionally, I recover the original one. --- GHUI/Web UI/createdInput.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GHUI/Web UI/createdInput.html b/GHUI/Web UI/createdInput.html index c7767a0..c816a8c 100644 --- a/GHUI/Web UI/createdInput.html +++ b/GHUI/Web UI/createdInput.html @@ -1 +1 @@ -UIUI

HELLO THERE

\ No newline at end of file +