From 1bda2478d7f8f49e238edb5f14ca8ae6d5e1b635 Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Fri, 9 Sep 2022 12:10:59 +0200 Subject: [PATCH] Merge pull request #1603 from specklesystems/hotfix/gh/duplicate-top-menu fix(gh): Unload top-menu if it exists before loading --- ConnectorGrasshopper/ConnectorGrasshopper/Loader.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ConnectorGrasshopper/ConnectorGrasshopper/Loader.cs b/ConnectorGrasshopper/ConnectorGrasshopper/Loader.cs index 661ac4ece8..81a096a72a 100755 --- a/ConnectorGrasshopper/ConnectorGrasshopper/Loader.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopper/Loader.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; @@ -120,8 +120,12 @@ private void HandleKitSelectedEvent(object sender, EventArgs args) private void AddSpeckleMenu(object sender, ElapsedEventArgs e) { if (Grasshopper.Instances.DocumentEditor == null || MenuHasBeenAdded) return; + var mainMenu = Grasshopper.Instances.DocumentEditor.MainMenuStrip; + var menuName = "Speckle 2"; + if (mainMenu.Items.ContainsKey(menuName)) + mainMenu.Items.RemoveByKey(menuName); - speckleMenu = new ToolStripMenuItem("Speckle 2"); + speckleMenu = new ToolStripMenuItem(menuName); var kitHeader = speckleMenu.DropDown.Items.Add("Select the converter you want to use."); kitHeader.Enabled = false; @@ -173,7 +177,6 @@ private void AddSpeckleMenu(object sender, ElapsedEventArgs e) try { - var mainMenu = Grasshopper.Instances.DocumentEditor.MainMenuStrip; Grasshopper.Instances.DocumentEditor.Invoke(new Action(() => { if (!MenuHasBeenAdded)