Clean up more errors

Contributes to CL-1051
This commit is contained in:
Ian Paschal 2018-10-16 09:34:50 +02:00
parent 1fa7a8880b
commit b99bc06d1c
5 changed files with 10 additions and 8 deletions

View file

@ -39,8 +39,8 @@ Item {
Popup { Popup {
id: popup; id: popup;
background: Item { background: Item {
height: popup.height; height: childrenRect.height;
width: popup.width; width: childrenRect.width;
DropShadow { DropShadow {
anchors.fill: pointedRectangle; anchors.fill: pointedRectangle;

View file

@ -77,6 +77,9 @@ Item {
UM.RecolorImage { UM.RecolorImage {
anchors.centerIn: parent; anchors.centerIn: parent;
color: { color: {
if (!printer) {
return "black";
}
if (printer.state == "disabled") { if (printer.state == "disabled") {
return UM.Theme.getColor("monitor_tab_text_inactive"); return UM.Theme.getColor("monitor_tab_text_inactive");
} }

View file

@ -35,7 +35,7 @@ Item {
PrinterInfoBlock { PrinterInfoBlock {
printer: root.printer; printer: root.printer;
printJob: root.printer.activePrintJob; printJob: root.printer ? root.printer.activePrintJob : null;
} }
HorizontalLine {} HorizontalLine {}
@ -45,7 +45,7 @@ Item {
width: parent.width; width: parent.width;
PrintJobTitle { PrintJobTitle {
job: root.printer.activePrintJob; job: root.printer ? root.printer.activePrintJob : null;
} }
PrintJobContextMenu { PrintJobContextMenu {
id: contextButton; id: contextButton;

View file

@ -19,7 +19,7 @@ ProgressBar {
} }
style: ProgressBarStyle { style: ProgressBarStyle {
property var remainingTime: { property var remainingTime: {
if (printer.activePrintJob == null) { if (!printer || printer.activePrintJob == null) {
return 0; return 0;
} }
/* Sometimes total minus elapsed is less than 0. Use Math.max() to prevent remaining /* Sometimes total minus elapsed is less than 0. Use Math.max() to prevent remaining
@ -28,7 +28,7 @@ ProgressBar {
return Math.max(printer.activePrintJob.timeTotal - printer.activePrintJob.timeElapsed, 0); return Math.max(printer.activePrintJob.timeTotal - printer.activePrintJob.timeElapsed, 0);
} }
property var progressText: { property var progressText: {
if (!printer.activePrintJob || !printer.activePrintJob.state ) { if (printer === null ) {
return ""; return "";
} }
switch (printer.activePrintJob.state) { switch (printer.activePrintJob.state) {
@ -64,7 +64,7 @@ ProgressBar {
progress: Rectangle { progress: Rectangle {
id: progressItem; id: progressItem;
color: { color: {
if (!printer.activePrintJob) { if (! printer || !printer.activePrintJob) {
return "black"; return "black";
} }
var state = printer.activePrintJob.state var state = printer.activePrintJob.state

View file

@ -24,7 +24,6 @@ Item {
anchors { anchors {
left: parent.left; left: parent.left;
right: parent.right; right: parent.right;
} }
height: childrenRect.height; height: childrenRect.height;
spacing: Math.round(0.5 * UM.Theme.getSize("default_margin").width); spacing: Math.round(0.5 * UM.Theme.getSize("default_margin").width);