From 485e37e7f5038ef7dd5ccb8dcc97b48c435b7fb5 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 20 Mar 2020 17:03:08 +0100 Subject: [PATCH] Extruders can be undefined, not null This happens when the printer is changed, such as when changing the Machine Width in the machine settings dialogue. It updates these menus then and if not all extruders are defined it'll give the following errors: 2020-03-20 16:56:57,839 - WARNING - [MainThread] UM.Qt.QtApplication.__onQmlWarning [406]: file:///home/trin/Gedeeld/Projects/Cura/resources/qml/Menus/SettingsMenu.qml:51: TypeError: Cannot read property 'isEnabled' of undefined 2020-03-20 16:56:57,840 - WARNING - [MainThread] UM.Qt.QtApplication.__onQmlWarning [406]: file:///home/trin/Gedeeld/Projects/Cura/resources/qml/Menus/SettingsMenu.qml:44: TypeError: Cannot read property 'isEnabled' of undefined 2020-03-20 16:56:57,841 - WARNING - [MainThread] UM.Qt.QtApplication.__onQmlWarning [406]: file:///home/trin/Gedeeld/Projects/Cura/resources/qml/Menus/MaterialMenu.qml:26: TypeError: Cannot read property 'isEnabled' of undefined 2020-03-20 16:56:57,841 - WARNING - [MainThread] UM.Qt.QtApplication.__onQmlWarning [406]: file:///home/trin/Gedeeld/Projects/Cura/resources/qml/Menus/MaterialMenu.qml:28: TypeError: Cannot read property 'material' of undefined Done during Turbo Testing and Tooling. --- resources/qml/Menus/MaterialMenu.qml | 8 ++++---- resources/qml/Menus/SettingsMenu.qml | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/resources/qml/Menus/MaterialMenu.qml b/resources/qml/Menus/MaterialMenu.qml index b733ead40b..b4f15fad00 100644 --- a/resources/qml/Menus/MaterialMenu.qml +++ b/resources/qml/Menus/MaterialMenu.qml @@ -1,5 +1,5 @@ -// Copyright (c) 2018 Ultimaker B.V. -// Cura is released under the terms of the LGPLv3 or higher. +//Copyright (c) 2020 Ultimaker B.V. +//Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.7 import QtQuick.Controls 1.4 @@ -23,9 +23,9 @@ Menu var activeMachine = Cura.MachineManager.activeMachine return (activeMachine === null) ? null : activeMachine.extruderList[extruderIndex] } - property bool isActiveExtruderEnabled: activeExtruder === null ? false : activeExtruder.isEnabled + property bool isActiveExtruderEnabled: (activeExtruder === null || activeExtruder === undefined) ? false : activeExtruder.isEnabled - property string activeMaterialId: activeExtruder === null ? false : activeExtruder.material.id + property string activeMaterialId: (activeExtruder === null || activeExtruder === undefined) ? false : activeExtruder.material.id property bool updateModels: true Cura.FavoriteMaterialsModel diff --git a/resources/qml/Menus/SettingsMenu.qml b/resources/qml/Menus/SettingsMenu.qml index 4e62c4d4e0..a7c8d7479f 100644 --- a/resources/qml/Menus/SettingsMenu.qml +++ b/resources/qml/Menus/SettingsMenu.qml @@ -1,5 +1,5 @@ -// Copyright (c) 2018 Ultimaker B.V. -// Cura is released under the terms of the LGPLv3 or higher. +//Copyright (c) 2020 Ultimaker B.V. +//Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.2 import QtQuick.Controls 1.1 @@ -41,14 +41,14 @@ Menu { text: catalog.i18nc("@action:inmenu", "Enable Extruder") onTriggered: Cura.MachineManager.setExtruderEnabled(model.index, true) - visible: extruder === null ? false : !extruder.isEnabled + visible: (extruder === null || extruder === undefined) ? false : !extruder.isEnabled } MenuItem { text: catalog.i18nc("@action:inmenu", "Disable Extruder") onTriggered: Cura.MachineManager.setExtruderEnabled(index, false) - visible: extruder === null ? false : extruder.isEnabled + visible: (extruder === null || extruder === undefined) ? false : extruder.isEnabled enabled: Cura.MachineManager.numberExtrudersEnabled > 1 }