Add extra checks to ensure backend exists, use same state everywhere

This commit is contained in:
ChrisTerBeke 2017-12-12 11:16:40 +01:00
parent 19e459d930
commit ca413e0496

View File

@ -49,12 +49,14 @@ Item {
} }
function sliceOrStopSlicing() { function sliceOrStopSlicing() {
if (backend != "undefined" && [1, 5].indexOf(UM.Backend.state) != -1) { if (base.backendState != "undefined" && backend !== "undefined") {
if ([1, 5].indexOf(base.backendState) != -1) {
backend.forceSlice(); backend.forceSlice();
} else { } else {
backend.stopSlicing(); backend.stopSlicing();
} }
} }
}
Label { Label {
id: statusLabel id: statusLabel
@ -165,7 +167,7 @@ Item {
Button { Button {
id: prepareButton id: prepareButton
tooltip: [1, 5].indexOf(UM.Backend.state) != -1 ? catalog.i18nc("@info:tooltip","Slice current printjob") : catalog.i18nc("@info:tooltip","Cancel slicing process") tooltip: [1, 5].indexOf(base.backendState) != -1 ? catalog.i18nc("@info:tooltip","Slice current printjob") : catalog.i18nc("@info:tooltip","Cancel slicing process")
// 1 = not started, 2 = Processing // 1 = not started, 2 = Processing
enabled: base.backendState != "undefined" && (base.backendState == 1 || base.backendState == 2) && base.activity == true enabled: base.backendState != "undefined" && (base.backendState == 1 || base.backendState == 2) && base.activity == true
visible: base.backendState != "undefined" && !autoSlice && (base.backendState == 1 || base.backendState == 2) && base.activity == true visible: base.backendState != "undefined" && !autoSlice && (base.backendState == 1 || base.backendState == 2) && base.activity == true
@ -177,7 +179,7 @@ Item {
anchors.rightMargin: UM.Theme.getSize("sidebar_margin").width anchors.rightMargin: UM.Theme.getSize("sidebar_margin").width
// 1 = not started, 5 = disabled // 1 = not started, 5 = disabled
text: [1, 5].indexOf(UM.Backend.state) != -1 ? catalog.i18nc("@label:Printjob", "Prepare") : catalog.i18nc("@label:Printjob", "Cancel") text: [1, 5].indexOf(base.backendState) != -1 ? catalog.i18nc("@label:Printjob", "Prepare") : catalog.i18nc("@label:Printjob", "Cancel")
onClicked: onClicked:
{ {
sliceOrStopSlicing(); sliceOrStopSlicing();