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.
This commit is contained in:
Ghostkeeper 2020-03-20 17:03:08 +01:00
parent 2f3462203c
commit 485e37e7f5
No known key found for this signature in database
GPG key ID: D2A8871EE34EC59A
2 changed files with 8 additions and 8 deletions

View file

@ -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
}