mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Fix handling of undefined printer items in AddLocalPrinterScrollView
This commit addresses an issue wherein undefined current items were not properly handled in the AddLocalPrinterScrollView module. We've changed the code so that it now checks if currentItem and currentItem.name exist before attempting to assign. If they don't exist, we now set default values to avoid null or undefined references. This prevents potential errors or inconsistent behaviors in the UI. CURA-11003
This commit is contained in:
parent
3908db7696
commit
1457569aeb
1 changed files with 8 additions and 3 deletions
|
@ -32,7 +32,7 @@ Item
|
|||
|
||||
onCurrentItemChanged:
|
||||
{
|
||||
printerName = currentItem == null ? "" : currentItem.name
|
||||
printerName = currentItem && currentItem.name? currentItem.name: ""
|
||||
}
|
||||
|
||||
function updateCurrentItemUponSectionChange(section)
|
||||
|
@ -53,12 +53,18 @@ Item
|
|||
{
|
||||
machineList.currentIndex = index;
|
||||
currentItem = machineList.model.getItem(index);
|
||||
if (currentItem != undefined)
|
||||
if (currentItem && currentItem.name)
|
||||
{
|
||||
machineName.text = currentItem.name
|
||||
manufacturer.text = currentItem.metadata["manufacturer"]
|
||||
author.text = currentItem.metadata["author"]
|
||||
}
|
||||
else
|
||||
{
|
||||
machineName.text = "No printers Found"
|
||||
manufacturer.text = ""
|
||||
author.text = ""
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted:
|
||||
|
@ -93,7 +99,6 @@ Item
|
|||
id: background
|
||||
color: UM.Theme.getColor("main_background")
|
||||
radius: 2
|
||||
border.width: 1
|
||||
border.color: UM.Theme.getColor("primary_button")
|
||||
}
|
||||
height: UM.Theme.getSize("small_button_icon").height*2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue