mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-23 14:44:13 -06:00
Use setCurrentIndex to switch tabs at activeExtruderChanged
This fixes a mysterious segfault. We still don't know why the segfault occurred though. All we know is that QML logs something about a binding loop on currentIndex, and Qt logs something about removing range [-1 through 0] from VisualItemModel. When the tab bar is then made visible, Cura crashes. It is a nondeterministic crash. After this change, we are not seeing it any more (but with any nondeterministic bug, it's hard to verify that it was actually fixed). Contributes to issue CURA-5876.
This commit is contained in:
parent
a62da4e523
commit
5d95d11437
1 changed files with 12 additions and 2 deletions
|
@ -42,8 +42,6 @@ Item
|
|||
anchors.topMargin: UM.Theme.getSize("default_margin").height
|
||||
visible: extrudersModel.count > 1
|
||||
|
||||
currentIndex: Math.max(Cura.ExtruderManager.activeExtruderIndex, 0)
|
||||
|
||||
Repeater
|
||||
{
|
||||
id: repeater
|
||||
|
@ -68,6 +66,18 @@ Item
|
|||
}
|
||||
}
|
||||
|
||||
//When active extruder changes for some other reason, switch tabs.
|
||||
//Don't directly link currentIndex to Cura.ExtruderManager.activeExtruderIndex!
|
||||
//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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue