Fix if you randomly click around in the materials then some spool_weights of 0 gets mixed up. The cause was that base.containerId was not updated at the same time as properties.guid. CURA-5408

This commit is contained in:
Jack Ha 2018-07-12 15:17:46 +02:00
parent 23d4e835ed
commit abbbdb17e6
2 changed files with 7 additions and 9 deletions

View File

@ -269,7 +269,7 @@ TabView
{
id: spoolWeightSpinBox
width: scrollView.columnWidth
value: base.getMaterialPreferenceValue(properties.guid, "spool_weight")
value: base.getMaterialPreferenceValue(properties.guid, "spool_weight", Cura.ContainerManager.getContainerMetaDataEntry(properties.container_id, "properties/weight"))
suffix: " g"
stepSize: 100
decimals: 0
@ -466,7 +466,7 @@ TabView
}
if(!spoolWeight)
{
spoolWeight = base.getMaterialPreferenceValue(properties.guid, "spool_weight");
spoolWeight = base.getMaterialPreferenceValue(properties.guid, "spool_weight", Cura.ContainerManager.getContainerMetaDataEntry(properties.container_id, "properties/weight"));
}
if (diameter == 0 || density == 0 || spoolWeight == 0)
@ -535,18 +535,14 @@ TabView
UM.Preferences.setValue("cura/material_settings", JSON.stringify(materialPreferenceValues));
}
function getMaterialPreferenceValue(material_guid, entry_name)
function getMaterialPreferenceValue(material_guid, entry_name, default_value)
{
if(material_guid in materialPreferenceValues && entry_name in materialPreferenceValues[material_guid])
{
return materialPreferenceValues[material_guid][entry_name];
}
if (entry_name === "spool_weight") {
// get the default value from the metadata
var material_weight = Cura.ContainerManager.getContainerMetaDataEntry(base.containerId, "properties/weight");
return material_weight || 0;
}
return 0;
default_value = default_value | 0;
return default_value;
}
// update the display name of the material

View File

@ -486,6 +486,7 @@ Item
materialProperties.name = currentItem.name ? currentItem.name : "Unknown";
materialProperties.guid = currentItem.guid;
materialProperties.container_id = currentItem.container_id;
materialProperties.brand = currentItem.brand ? currentItem.brand : "Unknown";
materialProperties.material = currentItem.material ? currentItem.material : "Unknown";
@ -543,6 +544,7 @@ Item
id: materialProperties
property string guid: "00000000-0000-0000-0000-000000000000"
property string container_id: "Unknown";
property string name: "Unknown";
property string profile_type: "Unknown";
property string brand: "Unknown";