Skip to content
This repository has been archived by the owner on Oct 4, 2021. It is now read-only.

[15.6][Mac] Fix crasher in MDMenu that happens if the command is not regist… #4214

Merged
merged 1 commit into from
Mar 19, 2018

Conversation

Therzok
Copy link
Contributor

@Therzok Therzok commented Mar 16, 2018

…ered before showing the menu

The code change is so that we use the virtual method on CommandEntry to get the actual command,
as that bit of code also registers the command in the command manager. (this is what the gtk backend
used to do)

Without doing that, we can end up having a commandentry for a command that has not been registered yet,
thus it will throw when trying to query the CommandInfo of a given command entry.

Fixes VSTS #584923 [Feedback] Using meny items crashes Visual Studio Mac

System.InvalidOperationException: Invalid action command id: MonoDevelop.Ide.CodeFormatting.CodeFormattingCommands.FormatBuffer
at MonoDevelop.Components.Commands.CommandManager.GetCommandInfo (System.Object commandId, MonoDevelop.Components.Commands.CommandTargetRoute targetRoute, System.Threading.CancellationToken cancelToken) [0x001f9] in /Users/builder/data/lanes/5810/05399106/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs:1718
at MonoDevelop.Components.Commands.CommandManager.GetCommandInfo (System.Object commandId, MonoDevelop.Components.Commands.CommandTargetRoute targetRoute) [0x00000] in /Users/builder/data/lanes/5810/05399106/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs:1608
at MonoDevelop.Components.Mac.MDMenuItem.Update (MonoDevelop.Components.Mac.MDMenu parent, System.Int32& index) [0x00000] in /Users/builder/data/lanes/5810/05399106/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/MDMenuItem.cs:114
at MonoDevelop.Components.Mac.MDMenu.UpdateCommands () [0x00037] in /Users/builder/data/lanes/5810/05399106/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/MDMenu.cs:157
at MonoDevelop.Components.Mac.MDSubMenuItem.Update (MonoDevelop.Components.Mac.MDMenu parent, System.Int32& index) [0x00000] in /Users/builder/data/lanes/5810/05399106/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/MDSubMenuItem.cs:48
at MonoDevelop.Components.Mac.MDMenu.UpdateCommands () [0x00037] in /Users/builder/data/lanes/5810/05399106/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/MDMenu.cs:157
at MonoDevelop.Components.Mac.MDMenu.MenuNeedsUpdate (AppKit.NSMenu menu) [0x00019] in /Users/builder/data/lanes/5810/05399106/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/MDMenu.cs:199
--- End of stack trace from previous location where exception was thrown ---
at (wrapper managed-to-native) Gtk.Application.gtk_main()
at Gtk.Application.Run () [0x00001] in /Users/builder/data/lanes/5533/mono-mac-sdk/external/bockbuild/builds/gtk-sharp-None/gtk/Application.cs:145
at MonoDevelop.Ide.IdeApp.Run () [0x00006] in /Users/builder/data/lanes/5810/05399106/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Ide.cs:404
at MonoDevelop.Ide.IdeStartup.Run (MonoDevelop.Ide.MonoDevelopOptions options) [0x00764] in /Users/builder/data/lanes/5810/05399106/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs:300
at MonoDevelop.Ide.IdeStartup.Main (System.String[] args, MonoDevelop.Ide.Extensions.IdeCustomizer customizer) [0x0008f] in /Users/builder/data/lanes/5810/05399106/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs:619

…ered before showing the menu

The code change is so that we use the virtual method on CommandEntry to get the actual command,
as that bit of code also registers the command in the command manager. (this is what the gtk backend
used to do)

Without doing that, we can end up having a commandentry for a command that has not been registered yet,
thus it will throw when trying to query the CommandInfo of a given command entry.

Fixes VSTS #584923 [Feedback] Using meny items crashes Visual Studio Mac

System.InvalidOperationException: Invalid action command id: MonoDevelop.Ide.CodeFormatting.CodeFormattingCommands.FormatBuffer
  at MonoDevelop.Components.Commands.CommandManager.GetCommandInfo (System.Object commandId, MonoDevelop.Components.Commands.CommandTargetRoute targetRoute, System.Threading.CancellationToken cancelToken) [0x001f9] in /Users/builder/data/lanes/5810/05399106/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs:1718
  at MonoDevelop.Components.Commands.CommandManager.GetCommandInfo (System.Object commandId, MonoDevelop.Components.Commands.CommandTargetRoute targetRoute) [0x00000] in /Users/builder/data/lanes/5810/05399106/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs:1608
  at MonoDevelop.Components.Mac.MDMenuItem.Update (MonoDevelop.Components.Mac.MDMenu parent, System.Int32& index) [0x00000] in /Users/builder/data/lanes/5810/05399106/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/MDMenuItem.cs:114
  at MonoDevelop.Components.Mac.MDMenu.UpdateCommands () [0x00037] in /Users/builder/data/lanes/5810/05399106/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/MDMenu.cs:157
  at MonoDevelop.Components.Mac.MDSubMenuItem.Update (MonoDevelop.Components.Mac.MDMenu parent, System.Int32& index) [0x00000] in /Users/builder/data/lanes/5810/05399106/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/MDSubMenuItem.cs:48
  at MonoDevelop.Components.Mac.MDMenu.UpdateCommands () [0x00037] in /Users/builder/data/lanes/5810/05399106/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/MDMenu.cs:157
  at MonoDevelop.Components.Mac.MDMenu.MenuNeedsUpdate (AppKit.NSMenu menu) [0x00019] in /Users/builder/data/lanes/5810/05399106/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/MDMenu.cs:199
--- End of stack trace from previous location where exception was thrown ---
  at (wrapper managed-to-native) Gtk.Application.gtk_main()
  at Gtk.Application.Run () [0x00001] in /Users/builder/data/lanes/5533/mono-mac-sdk/external/bockbuild/builds/gtk-sharp-None/gtk/Application.cs:145
  at MonoDevelop.Ide.IdeApp.Run () [0x00006] in /Users/builder/data/lanes/5810/05399106/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Ide.cs:404
  at MonoDevelop.Ide.IdeStartup.Run (MonoDevelop.Ide.MonoDevelopOptions options) [0x00764] in /Users/builder/data/lanes/5810/05399106/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs:300
  at MonoDevelop.Ide.IdeStartup.Main (System.String[] args, MonoDevelop.Ide.Extensions.IdeCustomizer customizer) [0x0008f] in /Users/builder/data/lanes/5810/05399106/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs:619
@Therzok Therzok modified the milestones: d15-6, 15.6 Mar 16, 2018
@Therzok Therzok changed the title [d15-6][Mac] Fix crasher in MDMenu that happens if the command is not regist… [15.6][Mac] Fix crasher in MDMenu that happens if the command is not regist… Mar 17, 2018
@GLjackyvaswani
Copy link

I can confirm that the bug is not reproducible using below build.
We have tried to test the bug as per the details shared in Bug and conversation had with Marius Ungureanu.

Issue seems to be fixed and ready to merge.

Scenarios Tested:

a) user removed keybinding setting for format document.
b) user used a right click menu in the editor, then went to the edit menu at the top.

Build Info:

Visual Studio Community 2017 for Mac
Version 7.4.1 (build 36)

Xamarin.Mac
Version: 4.2.0.82 (Visual Studio Community)
Xamarin.iOS
Version: 11.9.0.10 (Visual Studio Community)
Xamarin.Android
Version: 8.2.0.15 (Visual Studio Community)

Gist Link: https://gist.github.com/neerajdeshmukh/9aadb48b7cf26a3baa5317c9fd7a3658

Hence marking it as QA Approved.

Please feel free to Reopen.

@slluis slluis merged commit a071ce4 into d15-6 Mar 19, 2018
@slluis slluis deleted the d15-6-menu-crasher branch March 19, 2018 15:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants