From e591f3db5b43d60129120f43ad1cc282c29aa5ef Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 19 Jul 2021 17:34:44 +0200 Subject: [PATCH 1/3] Don't translate certain keywords in the application menu on MacOS There's a suspicion that this is causing a crash on exit. From the traceback it seems like it's attempting to find a certain property on a deleted item. I'm thinking it might be trying to update properties on an item that was already deleted by the system here because the item got moved to a system-specific menu. Qt doesn't realise that. By not translating that property, it's not necessary to update and hopefully this prevents the need to look up data on the deleted item. Not translating it is not an issue anyway, since the menu will also be renamed by Qt to some system-specific name, which is then also translated to the user's system-language by MacOS itself. It's not at all sure if this will fix it. Tests are necessary. Contributes to issue CURA-8245. --- resources/qml/Actions.qml | 22 +++++++++++++++--- resources/qml/MainWindow/ApplicationMenu.qml | 24 +++++++++++++++++--- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/resources/qml/Actions.qml b/resources/qml/Actions.qml index 7a4a837c66..bb9adc5b9f 100644 --- a/resources/qml/Actions.qml +++ b/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. pragma Singleton @@ -122,7 +122,15 @@ Item Action { 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" shortcut: StandardKey.Quit } @@ -263,7 +271,15 @@ Item Action { 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"; } diff --git a/resources/qml/MainWindow/ApplicationMenu.qml b/resources/qml/MainWindow/ApplicationMenu.qml index 95cea77248..50fe95bddb 100644 --- a/resources/qml/MainWindow/ApplicationMenu.qml +++ b/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. import QtQuick 2.7 @@ -48,7 +48,17 @@ Item 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 { @@ -91,7 +101,15 @@ Item Menu { 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") ? "P&references" : catalog.i18nc("@title:menu menubar:toplevel", "P&references") MenuItem { action: Cura.Actions.preferences } } From 109fce5211ac0edd3c02abc9d6345093651d0ec3 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 20 Jul 2021 15:22:44 +0200 Subject: [PATCH 2/3] Theoretical fix for MacOS not moving Preferences option any more Perhaps this ampersand was messing with it. Contributes to issue CURA-8245. --- resources/qml/MainWindow/ApplicationMenu.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/MainWindow/ApplicationMenu.qml b/resources/qml/MainWindow/ApplicationMenu.qml index 50fe95bddb..62b3a71ee8 100644 --- a/resources/qml/MainWindow/ApplicationMenu.qml +++ b/resources/qml/MainWindow/ApplicationMenu.qml @@ -109,7 +109,7 @@ Item //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") ? "P&references" : catalog.i18nc("@title:menu menubar:toplevel", "P&references") + title: (Qt.platform.os == "osx") ? "&Preferences" : catalog.i18nc("@title:menu menubar:toplevel", "P&references") MenuItem { action: Cura.Actions.preferences } } From e04a2b5e92954a4132266e6321185d07927d7779 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 21 Jul 2021 13:30:19 +0200 Subject: [PATCH 3/3] Also don't translate 'configure' keyword on MacOS Another attempt at finalising CURA-8245. --- resources/qml/Actions.qml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/resources/qml/Actions.qml b/resources/qml/Actions.qml index bb9adc5b9f..95c6778b87 100644 --- a/resources/qml/Actions.qml +++ b/resources/qml/Actions.qml @@ -180,7 +180,14 @@ Item Action { 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" }