Browse Source

Merge pull request #10169 from Ultimaker/CURA-8245_macos_crash_exit_translated

Fix crash on exit on MacOS if using Cura's translations
Vandresc 3 years ago
parent
commit
5f39de0a4c
2 changed files with 48 additions and 7 deletions
  1. 27 4
      resources/qml/Actions.qml
  2. 21 3
      resources/qml/MainWindow/ApplicationMenu.qml

+ 27 - 4
resources/qml/Actions.qml

@@ -1,4 +1,4 @@
-// Copyright (c) 2018 Ultimaker B.V.
+// Copyright (c) 2021 Ultimaker B.V.
 // Cura is released under the terms of the LGPLv3 or higher.
 // Cura is released under the terms of the LGPLv3 or higher.
 
 
 pragma Singleton
 pragma Singleton
@@ -122,7 +122,15 @@ Item
     Action
     Action
     {
     {
         id: quitAction
         id: quitAction
-        text: catalog.i18nc("@action:inmenu menubar:file","&Quit")
+
+        //On MacOS, don't translate the "Quit" word.
+        //Qt moves the "quit" entry to a different place, and if it got renamed can't find it again when it attempts to
+        //delete the item upon closing the application, causing a crash.
+        //In the new location, these items are translated automatically according to the system's language.
+        //For more information, see:
+        //- https://doc.qt.io/qt-5/macos-issues.html#menu-bar
+        //- https://doc.qt.io/qt-5/qmenubar.html#qmenubar-as-a-global-menu-bar
+        text: (Qt.platform.os == "osx") ? "&Quit" : catalog.i18nc("@action:inmenu menubar:file", "&Quit")
         iconName: "application-exit"
         iconName: "application-exit"
         shortcut: StandardKey.Quit
         shortcut: StandardKey.Quit
     }
     }
@@ -172,7 +180,14 @@ Item
     Action
     Action
     {
     {
         id: preferencesAction
         id: preferencesAction
-        text: catalog.i18nc("@action:inmenu", "Configure Cura...")
+        //On MacOS, don't translate the "Configure" word.
+        //Qt moves the "configure" entry to a different place, and if it got renamed can't find it again when it
+        //attempts to delete the item upon closing the application, causing a crash.
+        //In the new location, these items are translated automatically according to the system's language.
+        //For more information, see:
+        //- https://doc.qt.io/qt-5/macos-issues.html#menu-bar
+        //- https://doc.qt.io/qt-5/qmenubar.html#qmenubar-as-a-global-menu-bar
+        text: (Qt.platform.os == "osx") ? "Configure Cura..." : catalog.i18nc("@action:inmenu", "Configure Cura...")
         iconName: "configure"
         iconName: "configure"
     }
     }
 
 
@@ -263,7 +278,15 @@ Item
     Action
     Action
     {
     {
         id: aboutAction;
         id: aboutAction;
-        text: catalog.i18nc("@action:inmenu menubar:help", "About...");
+
+        //On MacOS, don't translate the "About" word.
+        //Qt moves the "about" entry to a different place, and if it got renamed can't find it again when it
+        //attempts to delete the item upon closing the application, causing a crash.
+        //In the new location, these items are translated automatically according to the system's language.
+        //For more information, see:
+        //- https://doc.qt.io/qt-5/macos-issues.html#menu-bar
+        //- https://doc.qt.io/qt-5/qmenubar.html#qmenubar-as-a-global-menu-bar
+        text: (Qt.platform.os == "osx") ? "About..." : catalog.i18nc("@action:inmenu menubar:help", "About...");
         iconName: "help-about";
         iconName: "help-about";
     }
     }
 
 

+ 21 - 3
resources/qml/MainWindow/ApplicationMenu.qml

@@ -1,4 +1,4 @@
-// Copyright (c) 2018 Ultimaker B.V.
+// Copyright (c) 2021 Ultimaker B.V.
 // Cura is released under the terms of the LGPLv3 or higher.
 // Cura is released under the terms of the LGPLv3 or higher.
 
 
 import QtQuick 2.7
 import QtQuick 2.7
@@ -48,7 +48,17 @@ Item
 
 
         ViewMenu { title: catalog.i18nc("@title:menu menubar:toplevel", "&View") }
         ViewMenu { title: catalog.i18nc("@title:menu menubar:toplevel", "&View") }
 
 
-        SettingsMenu { title: catalog.i18nc("@title:menu menubar:toplevel", "&Settings") }
+        SettingsMenu
+        {
+            //On MacOS, don't translate the "Settings" word.
+            //Qt moves the "settings" entry to a different place, and if it got renamed can't find it again when it
+            //attempts to delete the item upon closing the application, causing a crash.
+            //In the new location, these items are translated automatically according to the system's language.
+            //For more information, see:
+            //- https://doc.qt.io/qt-5/macos-issues.html#menu-bar
+            //- https://doc.qt.io/qt-5/qmenubar.html#qmenubar-as-a-global-menu-bar
+            title: (Qt.platform.os == "osx") ? "&Settings" : catalog.i18nc("@title:menu menubar:toplevel", "&Settings")
+        }
 
 
         Menu
         Menu
         {
         {
@@ -91,7 +101,15 @@ Item
         Menu
         Menu
         {
         {
             id: preferencesMenu
             id: preferencesMenu
-            title: catalog.i18nc("@title:menu menubar:toplevel", "P&references")
+
+            //On MacOS, don't translate the "Preferences" word.
+            //Qt moves the "preferences" entry to a different place, and if it got renamed can't find it again when it
+            //attempts to delete the item upon closing the application, causing a crash.
+            //In the new location, these items are translated automatically according to the system's language.
+            //For more information, see:
+            //- https://doc.qt.io/qt-5/macos-issues.html#menu-bar
+            //- https://doc.qt.io/qt-5/qmenubar.html#qmenubar-as-a-global-menu-bar
+            title: (Qt.platform.os == "osx") ? "&Preferences" : catalog.i18nc("@title:menu menubar:toplevel", "P&references")
 
 
             MenuItem { action: Cura.Actions.preferences }
             MenuItem { action: Cura.Actions.preferences }
         }
         }