Fix an issue that caused a non-deterministic segfault

Also add a topMargin only when there are tabs in the custom print setup.

Contributes to CURA-5941.
This commit is contained in:
Diego Prado Gesto 2018-12-05 13:30:01 +01:00
parent 909b0f3f7e
commit 0e22f6b672

View File

@ -52,8 +52,6 @@ Item
rightMargin: parent.padding rightMargin: parent.padding
} }
currentIndex: Math.max(Cura.ExtruderManager.activeExtruderIndex, 0)
Repeater Repeater
{ {
id: repeater id: repeater
@ -76,15 +74,27 @@ Item
} }
} }
// When the model of the extruders is rebuilt, the list of extruders is briefly emptied and rebuilt. //When active extruder changes for some other reason, switch tabs.
// This causes the currentIndex of the tab to be in an invalid position which resets it to 0. //Don't directly link currentIndex to Cura.ExtruderManager.activeExtruderIndex!
// Therefore we need to change it back to what it was: The active extruder index. //This causes a segfault in Qt 5.11. Something with VisualItemModel removing index -1. We have to use setCurrentIndex instead.
Connections
{
target: Cura.ExtruderManager
onActiveExtruderChanged:
{
tabBar.setCurrentIndex(Cura.ExtruderManager.activeExtruderIndex);
}
}
//When the model of the extruders is rebuilt, the list of extruders is briefly emptied and rebuilt.
//This causes the currentIndex of the tab to be in an invalid position which resets it to 0.
//Therefore we need to change it back to what it was: The active extruder index.
Connections Connections
{ {
target: repeater.model target: repeater.model
onModelChanged: onModelChanged:
{ {
tabBar.currentIndex = Math.max(Cura.ExtruderManager.activeExtruderIndex, 0) tabBar.setCurrentIndex(Cura.ExtruderManager.activeExtruderIndex)
} }
} }
} }
@ -94,7 +104,7 @@ Item
height: UM.Theme.getSize("print_setup_widget").height height: UM.Theme.getSize("print_setup_widget").height
anchors anchors
{ {
top: tabBar.bottom top: tabBar.visible ? tabBar.bottom : globalProfileRow.bottom
left: parent.left left: parent.left
leftMargin: parent.padding leftMargin: parent.padding
right: parent.right right: parent.right