From 34550e3a0775c83a417cdaa1493b04c3c7c7e22f Mon Sep 17 00:00:00 2001 From: Jose Medrano Date: Mon, 28 Oct 2019 14:15:56 +0100 Subject: [PATCH] Handles disposed windows when they are closed while the windows loop --- .../WindowCommands.cs | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/WindowCommands.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/WindowCommands.cs index 230a36b320c..24c46b9fbab 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/WindowCommands.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/WindowCommands.cs @@ -253,26 +253,39 @@ internal class OpenWindowListHandler : CommandHandler protected override void Update (CommandArrayInfo info) { foreach (Components.Window window in IdeApp.CommandService.TopLevelWindowStack) { + + string title = null; + bool hasTopLevel = false; + + try { + title = window.Title; + hasTopLevel = window.HasTopLevelFocus; #if !WINDOWS - //we don't want include hidden windows - if (!window.IsRealized || !window.IsVisible || Components.Mac.GtkMacInterop.IsGdkQuartzWindow (window)) - continue; + //we don't want include hidden windows + if (!window.IsRealized || !window.IsVisible || Components.Mac.GtkMacInterop.IsGdkQuartzWindow (window)) + continue; #endif + } catch (System.Exception ex) { + LoggingService.LogInternalError (ex); + //we log the issue + continue; + } + //Create CommandInfo object var commandInfo = new CommandInfo (); - commandInfo.Text = window.Title.Replace ("_", "__").Replace ("-", "\u2013").Replace (" \u2013 " + BrandingService.ApplicationName, ""); + commandInfo.Text = title.Replace ("_", "__").Replace ("-", "\u2013").Replace (" \u2013 " + BrandingService.ApplicationName, ""); if (string.IsNullOrEmpty (commandInfo.Text)) { commandInfo.Text = GettextCatalog.GetString ("No description"); } - if (window.HasTopLevelFocus) + if (hasTopLevel) commandInfo.Checked = true; commandInfo.Description = GettextCatalog.GetString ("Activate window '{0}'", commandInfo.Text); //Add menu item - info.Add (commandInfo, window.Title); + info.Add (commandInfo, title); } }