From 18be37d464e772e8ac7659a694da00e15afd19df Mon Sep 17 00:00:00 2001 From: LarsBrubaker Date: Thu, 24 Mar 2022 08:32:32 -0700 Subject: [PATCH] fixing null refernces --- .../DesignTools/PublicPropertyEditor.cs | 6 ++++++ .../MatterControl/PlatingHistoryContainer.cs | 14 +++++++++++--- MatterControlLib/PartPreviewWindow/Tabs.cs | 12 +++++++++--- Submodules/agg-sharp | 2 +- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/MatterControlLib/DesignTools/PublicPropertyEditor.cs b/MatterControlLib/DesignTools/PublicPropertyEditor.cs index c9f495e97..5a0ac7795 100644 --- a/MatterControlLib/DesignTools/PublicPropertyEditor.cs +++ b/MatterControlLib/DesignTools/PublicPropertyEditor.cs @@ -297,6 +297,12 @@ namespace MatterHackers.MatterControl.DesignTools public static GuiWidget CreatePropertyEditor(SafeList rows, EditableProperty property, UndoBuffer undoBuffer, PPEContext context, ThemeConfig theme) { + if (property == null + || context == null) + { + return null; + } + var localItem = context.item; var object3D = property.Item; var propertyGridModifier = property.Item as IPropertyGridModifier; diff --git a/MatterControlLib/Library/Providers/MatterControl/PlatingHistoryContainer.cs b/MatterControlLib/Library/Providers/MatterControl/PlatingHistoryContainer.cs index 0ee26ce89..f2209bf37 100644 --- a/MatterControlLib/Library/Providers/MatterControl/PlatingHistoryContainer.cs +++ b/MatterControlLib/Library/Providers/MatterControl/PlatingHistoryContainer.cs @@ -33,6 +33,7 @@ using System.IO; using System.Linq; using MatterHackers.Agg; using MatterHackers.Agg.Image; +using MatterHackers.Agg.UI; using MatterHackers.DataConverters3D; using MatterHackers.Localizations; using MatterHackers.MatterControl.DataStorage; @@ -83,9 +84,16 @@ namespace MatterHackers.MatterControl.Library internal ILibraryItem NewBedPlate(BedConfig bedConfig) { var name = bedConfig.Printer.PrinterName; - string now = DateTime.Now.ToString("yyyy-MM-dd HH_mm_ss"); - var filename = ApplicationController.Instance.SanitizeFileName($"{name} - {now}.mcx"); - string mcxPath = Path.Combine(this.FullPath, filename); + var mcxPath = ""; + var startTime = UiThread.CurrentTimerMs; + // try to get a valid filename for up to 3 seconds (3 tries at an unused filename) + while (File.Exists(mcxPath) + && UiThread.CurrentTimerMs < startTime + 3000) + { + string now = DateTime.Now.ToString("yyyy-MM-dd HH_mm_ss"); + var filename = ApplicationController.Instance.SanitizeFileName($"{name} - {now}.mcx"); + mcxPath = Path.Combine(this.FullPath, filename); + } File.WriteAllText(mcxPath, new Object3D().ToJson().Result); diff --git a/MatterControlLib/PartPreviewWindow/Tabs.cs b/MatterControlLib/PartPreviewWindow/Tabs.cs index 8b7f19426..1f33eb984 100644 --- a/MatterControlLib/PartPreviewWindow/Tabs.cs +++ b/MatterControlLib/PartPreviewWindow/Tabs.cs @@ -265,11 +265,17 @@ namespace MatterHackers.MatterControl.PartPreviewWindow this.TabBar.MouseMove += (s, e) => { - if (e?.DragFiles?.Count > 0 - && e.DragFiles.Where(f => ApplicationController.ShellFileExtensions.Contains(Path.GetExtension(f).ToLower())).Any()) + try { - e.AcceptDrop = true; + if (e?.DragFiles?.Count > 0 + && e.DragFiles.Where(f => ApplicationController.ShellFileExtensions.Contains(Path.GetExtension(f).ToLower())).Any()) + { + e.AcceptDrop = true; + } } + catch + { + } }; TabBar.MouseEnterBounds += (s, e) => diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 11ebc78b7..d3ceb0f48 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 11ebc78b76712d4a34c1fade8030a29f2799261b +Subproject commit d3ceb0f48a56be29dcd7639d92371a8f1e27f422