Make options not crash away if they don't exist
...just leave them invalid
This commit is contained in:
parent
6db05592da
commit
2e51bfaab3
1 changed files with 7 additions and 5 deletions
|
@ -103,13 +103,14 @@ Page {
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
switch(tag) {
|
switch(tag) {
|
||||||
case IppMsg.Integer:
|
case IppMsg.Integer:
|
||||||
|
var valid = printer.attrs.hasOwnProperty(name+"-supported")
|
||||||
loader.setSource("../components/IntegerSetting.qml",
|
loader.setSource("../components/IntegerSetting.qml",
|
||||||
{name: name,
|
{name: name,
|
||||||
prettyName: prettyName,
|
prettyName: prettyName,
|
||||||
tag: tag,
|
tag: tag,
|
||||||
valid: printer.attrs.hasOwnProperty(name+"-supported"),
|
valid: valid,
|
||||||
low: printer.attrs[name+"-supported"].value.low,
|
low: valid ? printer.attrs[name+"-supported"].value.low : 0,
|
||||||
high: printer.attrs[name+"-supported"].value.high,
|
high: valid ? printer.attrs[name+"-supported"].value.high : 0,
|
||||||
default_choice: printer.attrs.hasOwnProperty(name+"-default") ? printer.attrs[name+"-default"].value : undefined
|
default_choice: printer.attrs.hasOwnProperty(name+"-default") ? printer.attrs[name+"-default"].value : undefined
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
|
@ -129,12 +130,13 @@ Page {
|
||||||
case IppMsg.Enum:
|
case IppMsg.Enum:
|
||||||
case IppMsg.Keyword:
|
case IppMsg.Keyword:
|
||||||
case IppMsg.MimeMediaType:
|
case IppMsg.MimeMediaType:
|
||||||
|
var valid = printer.attrs.hasOwnProperty(name+"-supported")
|
||||||
loader.setSource("../components/ChoiceSetting.qml",
|
loader.setSource("../components/ChoiceSetting.qml",
|
||||||
{name: name,
|
{name: name,
|
||||||
prettyName: prettyName,
|
prettyName: prettyName,
|
||||||
tag: tag,
|
tag: tag,
|
||||||
valid: printer.attrs.hasOwnProperty(name+"-supported"),
|
valid: valid,
|
||||||
choices: printer.attrs[name+"-supported"].value,
|
choices: valid ? printer.attrs[name+"-supported"].value : [],
|
||||||
default_choice: printer.attrs.hasOwnProperty(name+"-default") ? printer.attrs[name+"-default"].value : "",
|
default_choice: printer.attrs.hasOwnProperty(name+"-default") ? printer.attrs[name+"-default"].value : "",
|
||||||
mime_type: Mimer.get_type(selectedFile)
|
mime_type: Mimer.get_type(selectedFile)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue