Prevent auto selecting an invalid printer

CURA-6483
This commit is contained in:
Lipu Fei 2019-05-03 08:48:35 +02:00
parent 5b9c4e402e
commit 7d4c821551
2 changed files with 17 additions and 4 deletions

View file

@ -76,15 +76,28 @@ Item
Component.onCompleted:
{
// Select the first one that's not "unknown" by default.
var toSelectIndex = -1
// Select the first one that's not "unknown" and is the host a group by default.
for (var i = 0; i < count; i++)
{
if (!model[i].isUnknownMachineType)
if (!model[i].isUnknownMachineType && model[i].isHostOfGroup)
{
currentIndex = i
toSelectIndex = i
break
}
}
currentIndex = toSelectIndex
}
// CURA-6483 For some reason currentIndex can be reset to 0. This check is here to prevent automatically
// selecting an unknown or non-host printer.
onCurrentIndexChanged:
{
var item = model[currentIndex]
if (!item || item.isUnknownMachineType || !item.isHostOfGroup)
{
currentIndex = -1
}
}
Component