diff options
author | Matt Ward <matt.ward@microsoft.com> | 2020-01-10 15:16:53 +0300 |
---|---|---|
committer | monojenkins <jo.shields+jenkins@xamarin.com> | 2020-01-10 15:28:50 +0300 |
commit | 65dfdeafffaf53491bcdc22b544098ad80edba3d (patch) | |
tree | 1be37fe411d9b765ba2a98ded307f26c98cc38c4 /main | |
parent | 3e7d480263d9f618faa2ba866228f44aa60d3a8e (diff) |
[Ide] Fix crash in main toolbar after project is reloaded
If a multi-run configuration is selected in the main toolbar and a
project is reloaded a crash can occur since the main toolbar has not
updated its project mappings. Exception thrown:
System.Collections.Generic.KeyNotFoundException: The given key
'MonoDevelop.CSharp.Project.CSharpProject' was not present in the
dictionary.
System.ThrowHelper.GetKeyNotFoundException(Object)
System.ThrowHelper.ThrowKeyNotFoundException(Object)
System.Collections.Generic.Dictionary`2[[MonoDevelop.Projects.SolutionItem],[MonoDevelop.Components.MainToolbar.ConfigurationMerger]].get_Item(SolutionItem)
MonoDevelop.Components.MainToolbar.MainToolbarController.FillRuntimesForProject(List`1,SolutionItem,Int32&)
MonoDevelop.Components.MainToolbar.MainToolbarController.FillRuntimes()
MonoDevelop.Components.MainToolbar.MainToolbarController.NotifyConfigurationChange()
MonoDevelop.Components.MainToolbar.MainToolbarController.HandleRuntimeChanged(Object,HandledEventArgs)
The problem was that on reloading the main toolbar's configurationMerger
dictionary was not updated. It still contained the old disposed project
so the dictionary lookup would fail for the new reloaded project. To
fix this when a project is reloaded the main toolbar's dictionary is
now refreshed.
Repro:
1. Create a solution with two projects.
2. Create a multiple startup run configuration with both projects.
3. Select the multi run configuration in the toolbar.
4. Edit one of the project files in the editor and save a change.
5. Change from Debug to Release in the main toolbar.
Fixes VSTS #944654 - [FATAL] System.Collections.Generic.KeyNotFoundException
exception in System.ThrowHelper.GetKeyNotFoundException()
Diffstat (limited to 'main')
-rw-r--r-- | main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs index a9763a1510..62986247a3 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs @@ -574,6 +574,7 @@ namespace MonoDevelop.Components.MainToolbar currentSolution.StartupConfigurationChanged -= HandleStartupItemChanged; currentSolution.Saved -= HandleSolutionSaved; currentSolution.EntrySaved -= HandleSolutionEntrySaved; + currentSolution.SolutionItemAdded -= HandleSolutionItemAdded; } currentSolution = e.Solution; @@ -582,6 +583,7 @@ namespace MonoDevelop.Components.MainToolbar currentSolution.StartupConfigurationChanged += HandleStartupItemChanged; currentSolution.Saved += HandleSolutionSaved; currentSolution.EntrySaved += HandleSolutionEntrySaved; + currentSolution.SolutionItemAdded += HandleSolutionItemAdded; } TrackStartupProject (); @@ -624,6 +626,14 @@ namespace MonoDevelop.Components.MainToolbar HandleSolutionSaved (sender, e); } + void HandleSolutionItemAdded (object sender, SolutionItemChangeEventArgs e) + { + // When a solution item is added due to a reload we need to ensure the configurationMergers dictionary is + // using the new project and not the old disposed project. + if (e.Reloading) + UpdateCombos (); + } + void HandleStartupItemChanged (object sender, EventArgs e) { TrackStartupProject (); |