diff options
author | Diego Prado Gesto <d.pradogesto@ultimaker.com> | 2018-12-05 15:30:01 +0300 |
---|---|---|
committer | Diego Prado Gesto <d.pradogesto@ultimaker.com> | 2018-12-05 15:30:01 +0300 |
commit | 0e22f6b672a29c8b57309332a1f77355f151f870 (patch) | |
tree | b6b7a000e7da7d93543644e13c96872592d416f3 | |
parent | 909b0f3f7e7b228003b448d41a5a98398d756d74 (diff) |
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.
-rw-r--r-- | resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml index 8b0f3524d7..b28c9ceb46 100644 --- a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml @@ -52,8 +52,6 @@ Item rightMargin: parent.padding } - currentIndex: Math.max(Cura.ExtruderManager.activeExtruderIndex, 0) - 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. - // 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. + //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. Connections { target: repeater.model 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 anchors { - top: tabBar.bottom + top: tabBar.visible ? tabBar.bottom : globalProfileRow.bottom left: parent.left leftMargin: parent.padding right: parent.right |