Author: lluis
Date: 2007-05-25 13:11:08 -0400 (Fri, 25 May 2007)
New Revision: 77954
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Components/ChangeLog
trunk/monodevelop/Core/src/MonoDevelop.Components/MonoDevelop.Components.Commands/CommandEntry.cs
trunk/monodevelop/Core/src/MonoDevelop.Components/MonoDevelop.Components.Commands/CommandManager.cs
trunk/monodevelop/Core/src/MonoDevelop.Components/MonoDevelop.Components.Commands/LocalCommandEntry.cs
trunk/monodevelop/Core/src/MonoDevelop.Components/MonoDevelop.Components.DockToolbars/ArrowWindow.cs
Log:
* MonoDevelop.Components.DockToolbars/ArrowWindow.cs: Fix warning.
* MonoDevelop.Components.Commands/LocalCommandEntry.cs,
MonoDevelop.Components.Commands/CommandManager.cs,
MonoDevelop.Components.Commands/CommandEntry.cs: Don't crash when
creating a menu which references a command which has not been
registered. Added method for unregistering commands.
Modified: trunk/monodevelop/Core/src/MonoDevelop.Components/ChangeLog
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Components/ChangeLog 2007-05-25
17:08:04 UTC (rev 77953)
+++ trunk/monodevelop/Core/src/MonoDevelop.Components/ChangeLog 2007-05-25
17:11:08 UTC (rev 77954)
@@ -1,3 +1,12 @@
+2007-05-25 Lluis Sanchez Gual <[EMAIL PROTECTED]>
+
+ * MonoDevelop.Components.DockToolbars/ArrowWindow.cs: Fix warning.
+ * MonoDevelop.Components.Commands/LocalCommandEntry.cs,
+ MonoDevelop.Components.Commands/CommandManager.cs,
+ MonoDevelop.Components.Commands/CommandEntry.cs: Don't crash when
+ creating a menu which references a command which has not been
+ registered. Added method for unregistering commands.
+
2007-05-09 Lluis Sanchez Gual <[EMAIL PROTECTED]>
* Makefile.am: Reference shared assemblies from the correct location.
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Components/MonoDevelop.Components.Commands/CommandEntry.cs
===================================================================
---
trunk/monodevelop/Core/src/MonoDevelop.Components/MonoDevelop.Components.Commands/CommandEntry.cs
2007-05-25 17:08:04 UTC (rev 77953)
+++
trunk/monodevelop/Core/src/MonoDevelop.Components/MonoDevelop.Components.Commands/CommandEntry.cs
2007-05-25 17:11:08 UTC (rev 77954)
@@ -55,6 +55,9 @@
return new Gtk.SeparatorToolItem ();
Command cmd = manager.GetCommand (cmdId);
+ if (cmd == null)
+ return new Gtk.ToolItem ();
+
if (cmd is CustomCommand) {
Gtk.Widget child = (Gtk.Widget)
Activator.CreateInstance (((CustomCommand)cmd).WidgetType);
Gtk.ToolItem ti = new Gtk.ToolItem ();
@@ -88,6 +91,9 @@
return new Gtk.SeparatorMenuItem ();
Command cmd = manager.GetCommand (cmdId);
+ if (cmd == null)
+ return new Gtk.MenuItem ("<Unknown Command>");
+
if (cmd is CustomCommand) {
Gtk.Widget child = (Gtk.Widget)
Activator.CreateInstance (((CustomCommand)cmd).WidgetType);
CustomMenuItem ti = new CustomMenuItem ();
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Components/MonoDevelop.Components.Commands/CommandManager.cs
===================================================================
---
trunk/monodevelop/Core/src/MonoDevelop.Components/MonoDevelop.Components.Commands/CommandManager.cs
2007-05-25 17:08:04 UTC (rev 77953)
+++
trunk/monodevelop/Core/src/MonoDevelop.Components/MonoDevelop.Components.Commands/CommandManager.cs
2007-05-25 17:11:08 UTC (rev 77954)
@@ -144,6 +144,20 @@
}
}
+ public void UnregisterCommand (Command cmd)
+ {
+ if (cmd.AccelKey != null && cmd.AccelKey != "") {
+ // Unregister overloaded key bindings
+ ArrayList list = (ArrayList)
overloadedAccelCommands [cmd.AccelKey];
+ if (list != null) {
+ list.Remove (cmd.Id);
+ if (list.Count < 2)
+ overloadedAccelCommands.Remove
(cmd.AccelKey);
+ }
+ }
+ cmds.Remove (cmd.Id);
+ }
+
public void RegisterGlobalHandler (object handler)
{
if (!globalHandlers.Contains (handler))
@@ -171,23 +185,12 @@
public Command GetCommand (object cmdId)
{
- Command cmd = cmds [cmdId] as Command;
- if (cmd == null)
- throw new InvalidOperationException ("Invalid
command id: " + cmdId);
- return cmd;
- }
-
- internal Command FindCommand (object cmdId)
- {
return cmds [cmdId] as Command;
}
public ActionCommand GetActionCommand (object cmdId)
{
- ActionCommand cmd = cmds [cmdId] as ActionCommand;
- if (cmd == null)
- throw new InvalidOperationException ("Invalid
action command id: " + cmdId);
- return cmd;
+ return cmds [cmdId] as ActionCommand;
}
public Gtk.MenuBar CreateMenuBar (string name, CommandEntrySet
entrySet)
@@ -273,6 +276,8 @@
ActionCommand cmd = null;
try {
cmd = GetActionCommand (commandId);
+ if (cmd == null)
+ return false;
int globalPos = -1;
object cmdTarget = initialTarget != null ?
initialTarget : GetFirstCommandTarget (out globalPos);
@@ -336,6 +341,9 @@
internal CommandInfo GetCommandInfo (object commandId, object
initialTarget)
{
ActionCommand cmd = GetActionCommand (commandId);
+ if (cmd == null)
+ throw new InvalidOperationException ("Invalid
action command id: " + commandId);
+
CommandInfo info = new CommandInfo (cmd);
try {
@@ -428,6 +436,9 @@
// but checking all possible commands would be too slow.
Command cmd = GetCommand (commandId);
+ if (cmd == null)
+ return false;
+
string accel = cmd.AccelKey;
if (accel == null || accel == "")
return DispatchCommand (commandId, dataItem,
initialTarget);
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Components/MonoDevelop.Components.Commands/LocalCommandEntry.cs
===================================================================
---
trunk/monodevelop/Core/src/MonoDevelop.Components/MonoDevelop.Components.Commands/LocalCommandEntry.cs
2007-05-25 17:08:04 UTC (rev 77953)
+++
trunk/monodevelop/Core/src/MonoDevelop.Components/MonoDevelop.Components.Commands/LocalCommandEntry.cs
2007-05-25 17:11:08 UTC (rev 77954)
@@ -48,7 +48,7 @@
internal protected override Gtk.MenuItem CreateMenuItem
(CommandManager manager)
{
- if (manager.FindCommand (CommandId) == null)
+ if (manager.GetCommand (CommandId) == null)
manager.RegisterCommand (cmd, "");
return base.CreateMenuItem (manager);
@@ -56,7 +56,7 @@
internal protected override Gtk.ToolItem CreateToolItem
(CommandManager manager)
{
- if (manager.FindCommand (CommandId) == null)
+ if (manager.GetCommand (CommandId) == null)
manager.RegisterCommand (cmd, "");
return base.CreateToolItem (manager);
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Components/MonoDevelop.Components.DockToolbars/ArrowWindow.cs
===================================================================
---
trunk/monodevelop/Core/src/MonoDevelop.Components/MonoDevelop.Components.DockToolbars/ArrowWindow.cs
2007-05-25 17:08:04 UTC (rev 77953)
+++
trunk/monodevelop/Core/src/MonoDevelop.Components/MonoDevelop.Components.DockToolbars/ArrowWindow.cs
2007-05-25 17:11:08 UTC (rev 77954)
@@ -46,7 +46,7 @@
Gdk.GC redgc;
// Where does the arrow point to
- public enum Direction {
+ public new enum Direction {
Up, Down, Left, Right
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches