[smuxi: 4/12] Frontend-GNOME: workaround startup crash on Mac OS X with newer Mono versions



commit 9f41294ffb230893e488f5e1dca19a0b906b9a29
Author: Mirco Bauer <meebey meebey net>
Date:   Sat Aug 18 15:51:28 2018 +0800

    Frontend-GNOME: workaround startup crash on Mac OS X with newer Mono versions
    
    Smuxi no longer starts on OS X with Mono 5.10. Smuxi relies on the
    libigemacintegration.dylib library to integrate into the Mac menu. This library
    is shipped with the Mono runtime installation. Since Mono 5.10 this library no
    longer provides all symbols that Smuxi needs and thus crashes like this:
    
            Exception Type:
            System.EntryPointNotFoundException
    
            Exception Message:
            ige_mac_menu_set_global_key_handler_enabled
    
            Exception StackTrace:
              at (wrapper managed-to-native) 
IgeMacIntegration.IgeMacMenu.ige_mac_menu_set_global_key_handler_enabled(bool)
              at IgeMacIntegration.IgeMacMenu.set_GlobalKeyHandlerEnabled (System.Boolean value) [0x00001] in 
<759e3226a68c4d99981055802cb0cde6>:0
              at Smuxi.Frontend.Gnome.MenuWidget..ctor (Gtk.Window parent, 
Smuxi.Frontend.Gnome.ChatViewManager chatViewManager) [0x00261] in <759e3226a68c4d99981055802cb0cde6>:0
              at Smuxi.Frontend.Gnome.MainWindow..ctor () [0x003a8] in <759e3226a68c4d99981055802cb0cde6>:0
              at Smuxi.Frontend.Gnome.Frontend.Init (System.String[] args, System.String engine) [0x000cc] in 
<759e3226a68c4d99981055802cb0cde6>:0
              at Smuxi.Frontend.Gnome.MainClass.Main (System.String[] args) [0x00235] in 
<759e3226a68c4d99981055802cb0cde6>:0
    
    Really fixing this issue correctly is not straight forward because Smuxi should
    bundle the library itself. So the workaround for now is to initialize the mac
    menu integration with handling the exception and let Smuxi continue to start
    without the mac menu integration enabled.
    
    Thanks goes to Andres Aragoneses for reporting the issue, investigation and
    testing the workaround.

 src/Frontend-GNOME/Views/MenuWidget.cs | 46 ++++++++++++++++++----------------
 1 file changed, 25 insertions(+), 21 deletions(-)
---
diff --git a/src/Frontend-GNOME/Views/MenuWidget.cs b/src/Frontend-GNOME/Views/MenuWidget.cs
index 19a2cbd9..fa3eb5bf 100644
--- a/src/Frontend-GNOME/Views/MenuWidget.cs
+++ b/src/Frontend-GNOME/Views/MenuWidget.cs
@@ -136,27 +136,31 @@ namespace Smuxi.Frontend.Gnome
             f_ShowStatusbarAction.Active = (bool) Frontend.FrontendConfig["ShowStatusBar"];
 
             if (Frontend.IsMacOSX) {
-                // Smuxi menu is already shown as app menu
-                f_SmuxiAction.Visible = false;
-                // About item is already shown in app menu
-                f_AboutAction.Visible = false;
-
-                IgeMacMenu.GlobalKeyHandlerEnabled = true;
-                IgeMacMenu.MenuBar = f_MenuBar;
-                f_ShowMenubarAction.Active = false;
-                // no need for the menu bar as have the app menu
-                f_ShowMenubarAction.Visible = false;
-
-                var appGroup = IgeMacMenu.AddAppMenuGroup();
-                appGroup.AddMenuItem(
-                    (Gtk.MenuItem) f_AboutAction.CreateMenuItem(),
-                    _("About Smuxi")
-                );
-                var prefItem = (Gtk.MenuItem) f_PreferencesAction.CreateMenuItem();
-                // TODO: add cmd+, accelerator
-                appGroup.AddMenuItem(prefItem, _("Preferences"));
-                IgeMacMenu.QuitMenuItem = (Gtk.MenuItem)
-                    f_QuitAction.CreateMenuItem();
+                try {
+                    IgeMacMenu.GlobalKeyHandlerEnabled = true;
+                    IgeMacMenu.MenuBar = f_MenuBar;
+                    f_ShowMenubarAction.Active = false;
+                    // no need for the menu bar as have the app menu
+                    f_ShowMenubarAction.Visible = false;
+
+                    var appGroup = IgeMacMenu.AddAppMenuGroup();
+                    appGroup.AddMenuItem(
+                        (Gtk.MenuItem) f_AboutAction.CreateMenuItem(),
+                        _("About Smuxi")
+                    );
+                    var prefItem = (Gtk.MenuItem) f_PreferencesAction.CreateMenuItem();
+                    // TODO: add cmd+, accelerator
+                    appGroup.AddMenuItem(prefItem, _("Preferences"));
+                    IgeMacMenu.QuitMenuItem = (Gtk.MenuItem)
+                        f_QuitAction.CreateMenuItem();
+
+                    // Smuxi menu is already shown as app menu
+                    f_SmuxiAction.Visible = false;
+                    // About item is already shown in app menu
+                    f_AboutAction.Visible = false;
+                } catch (EntryPointNotFoundException ex) {
+                    f_Logger.Error("Failed to initialize mac menu integration, disabling mac menu 
integration", ex);
+                }
             }
         }
 


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