From 0e22f6b672a29c8b57309332a1f77355f151f870 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Wed, 5 Dec 2018 13:30:01 +0100 Subject: [PATCH] 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. --- .../Custom/CustomPrintSetup.qml | 24 +++++++++++++------ 1 file 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