From 7a63f957cb104f903d54d59fb628dbdbdd856c62 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Mon, 11 Jul 2016 15:48:41 +0200 Subject: [PATCH] More gracefully handle cases where no profile is selected in the profiles list --- resources/qml/Preferences/ProfilesPage.qml | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/resources/qml/Preferences/ProfilesPage.qml b/resources/qml/Preferences/ProfilesPage.qml index d6dd66e8a8..5a56ac8dc3 100644 --- a/resources/qml/Preferences/ProfilesPage.qml +++ b/resources/qml/Preferences/ProfilesPage.qml @@ -140,7 +140,7 @@ UM.ManagementPage Row { id: currentSettingsActions - visible: currentItem.id == Cura.MachineManager.activeQualityId + visible: currentItem && currentItem.id == Cura.MachineManager.activeQualityId anchors.left: parent.left anchors.top: profileName.bottom @@ -173,14 +173,14 @@ UM.ManagementPage Label { id: defaultsMessage - visible: !currentItem.metadata.has_settings + visible: currentItem && !currentItem.metadata.has_settings text: catalog.i18nc("@action:label", "This profile has no settings and uses the defaults specified by the printer.") wrapMode: Text.WordWrap width: parent.width } Label { id: noCurrentSettingsMessage - visible: currentItem.id == Cura.MachineManager.activeQualityId && !Cura.MachineManager.hasUserSettings + visible: currentItem && currentItem.id == Cura.MachineManager.activeQualityId && !Cura.MachineManager.hasUserSettings text: catalog.i18nc("@action:label", "Your current settings match the selected profile.") wrapMode: Text.WordWrap width: parent.width @@ -197,7 +197,17 @@ UM.ManagementPage anchors.bottom: parent.bottom ListView { - model: Cura.ContainerSettingsModel{ containers: (currentItem.id == Cura.MachineManager.activeQualityId) ? [base.currentItem.id, Cura.MachineManager.activeUserProfileId] : [base.currentItem.id] } + model: Cura.ContainerSettingsModel{ containers: + { + if (!currentItem) { + return [] + } else if (currentItem.id == Cura.MachineManager.activeQualityId) { + return [base.currentItem.id, Cura.MachineManager.activeUserProfileId] + } else { + return [base.currentItem.id] + } + } + } delegate: Row { property variant setting: model spacing: UM.Theme.getSize("default_margin").width/2 @@ -221,7 +231,7 @@ UM.ManagementPage } } header: Row { - visible: currentItem.id == Cura.MachineManager.activeQualityId + visible: currentItem && currentItem.id == Cura.MachineManager.activeQualityId spacing: UM.Theme.getSize("default_margin").width Label { text: catalog.i18nc("@action:label", "Profile:") @@ -231,7 +241,7 @@ UM.ManagementPage } Label { text: catalog.i18nc("@action:label", "Current:") - visible: currentItem.id == Cura.MachineManager.activeQualityId + visible: currentItem && currentItem.id == Cura.MachineManager.activeQualityId font.bold: true } }