[tomboy] Protect against PPC/ARM crash when showing menus (#586605, #593422)



commit 02e0eac75155ccd6f61b9d5271d67b06feefcb74
Author: Sanford Armstrong <sandy Nicolette-Vrsniks-Computer local>
Date:   Sun Sep 6 21:24:56 2009 -0700

    Protect against PPC/ARM crash when showing menus (#586605, #593422)
    
    This may result in less-than-optimal menu positioning for PPC/ARM users.
    I have filed BNC #537118 with the gtk-sharp guys.
    
    Other relevant bugs are LP #391124 and BTS #544022.

 Tomboy/RecentChanges.cs |   16 ++++++++++++----
 Tomboy/Utils.cs         |   30 +++++++++++++++---------------
 2 files changed, 27 insertions(+), 19 deletions(-)
---
diff --git a/Tomboy/RecentChanges.cs b/Tomboy/RecentChanges.cs
index ab95940..58823cf 100644
--- a/Tomboy/RecentChanges.cs
+++ b/Tomboy/RecentChanges.cs
@@ -838,10 +838,18 @@ namespace Tomboy
 			if (x == 0 && y == 0)
 				pos_menu_func = PositionContextMenu;
 
-			menu.Popup (null, null,
-				    pos_menu_func,
-				    0,
-				    Gtk.Global.CurrentEventTime);
+			try {
+				menu.Popup (null, null,
+					    pos_menu_func,
+					    0,
+					    Gtk.Global.CurrentEventTime);
+			} catch {
+				Logger.Debug ("Menu popup failed with custom MenuPositionFunc; trying again without");
+				menu.Popup (null, null,
+					    null,
+					    0,
+					    Gtk.Global.CurrentEventTime);
+			}
 		}
 
 		// This is needed for when the user opens
diff --git a/Tomboy/Utils.cs b/Tomboy/Utils.cs
index b074d74..92754b9 100644
--- a/Tomboy/Utils.cs
+++ b/Tomboy/Utils.cs
@@ -61,26 +61,26 @@ namespace Tomboy
 		// calling this.
 		public static void PopupMenu (Gtk.Menu menu, Gdk.EventButton ev)
 		{
-			menu.Deactivated += DeactivateMenu;
-			menu.Popup (null,
-			            null,
-			            new Gtk.MenuPositionFunc (GetMenuPosition),
-			            (ev == null) ? 0 : ev.Button,
-			            (ev == null) ? Gtk.Global.CurrentEventTime : ev.Time);
-
-			// Highlight the parent
-			if (menu.AttachWidget != null)
-				menu.AttachWidget.State = Gtk.StateType.Selected;
+			PopupMenu (menu, ev, new Gtk.MenuPositionFunc (GetMenuPosition));
 		}
 
 		public static void PopupMenu (Gtk.Menu menu, Gdk.EventButton ev, Gtk.MenuPositionFunc mpf)
 		{
 			menu.Deactivated += DeactivateMenu;
-			menu.Popup (null,
-			            null,
-			            mpf,
-			            (ev == null) ? 0 : ev.Button,
-			            (ev == null) ? Gtk.Global.CurrentEventTime : ev.Time);
+			try {
+				menu.Popup (null,
+				            null,
+				            mpf,
+				            (ev == null) ? 0 : ev.Button,
+				            (ev == null) ? Gtk.Global.CurrentEventTime : ev.Time);
+			} catch {
+				Logger.Debug ("Menu popup failed with custom MenuPositionFunc; trying again without");
+				menu.Popup (null,
+				            null,
+				            null,
+				            (ev == null) ? 0 : ev.Button,
+				            (ev == null) ? Gtk.Global.CurrentEventTime : ev.Time);
+			}
 
 			// Highlight the parent
 			if (menu.AttachWidget != null)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]