From 20777541c074af0219f9554081708f241f72a915 Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Fri, 27 Mar 2026 17:40:18 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20address=20review=20findings=20=E2=80=94?= =?UTF-8?q?=20MdiParent=20conflict,=20null=20guard,=20Drawing.Material?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix critical: use MdiParentForm (custom property) instead of MdiParent (WinForms property) in ImportBom_Click to avoid InvalidOperationException - Add null guard in CreateNests_Click - Set Drawing.Material from BOM group - Move DxfImporter creation outside loop - Improve summary label text with reason descriptions Co-Authored-By: Claude Opus 4.6 (1M context) --- OpenNest/Forms/BomImportForm.cs | 10 +++++++--- OpenNest/Forms/MainForm.cs | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/OpenNest/Forms/BomImportForm.cs b/OpenNest/Forms/BomImportForm.cs index a9e042a..e8da2c4 100644 --- a/OpenNest/Forms/BomImportForm.cs +++ b/OpenNest/Forms/BomImportForm.cs @@ -115,9 +115,9 @@ namespace OpenNest.Forms { var parts = new List(); if (analysis.Skipped.Count > 0) - parts.Add($"{analysis.Skipped.Count} skipped"); + parts.Add($"{analysis.Skipped.Count} skipped (no DXF file or thickness given)"); if (analysis.Unmatched.Count > 0) - parts.Add($"{analysis.Unmatched.Count} unmatched"); + parts.Add($"{analysis.Unmatched.Count} unmatched (DXF file not found)"); lblSummary.Text = parts.Count > 0 ? string.Join(", ", parts) @@ -126,6 +126,9 @@ namespace OpenNest.Forms private void CreateNests_Click(object sender, EventArgs e) { + if (_analysis == null || _analysis.Groups.Count == 0) + return; + if (!double.TryParse(txtPlateWidth.Text, out var plateWidth) || plateWidth <= 0) { MessageBox.Show("Plate width must be a positive number.", "Validation Error", @@ -141,6 +144,7 @@ namespace OpenNest.Forms } var jobName = txtJobName.Text.Trim(); + var importer = new DxfImporter(); var nestsCreated = 0; var importErrors = new List(); @@ -167,13 +171,13 @@ namespace OpenNest.Forms try { - var importer = new DxfImporter(); var result = importer.Import(matched.DxfPath); var drawingName = Path.GetFileNameWithoutExtension(matched.DxfPath); var drawing = new Drawing(drawingName); drawing.Source.Path = matched.DxfPath; drawing.Quantity.Required = matched.Item.Qty ?? 1; + drawing.Material = new Material(group.Material); var pgm = ConvertGeometry.ToProgram(result.Entities); diff --git a/OpenNest/Forms/MainForm.cs b/OpenNest/Forms/MainForm.cs index 8ca53bf..8314ce3 100644 --- a/OpenNest/Forms/MainForm.cs +++ b/OpenNest/Forms/MainForm.cs @@ -476,7 +476,7 @@ namespace OpenNest.Forms private void ImportBom_Click(object sender, EventArgs e) { var form = new BomImportForm(); - form.MdiParent = this; + form.MdiParentForm = this; form.ShowDialog(this); }