From ba178f21a4534206851f389edd66c5af77704a38 Mon Sep 17 00:00:00 2001 From: Jack Harper Date: Wed, 24 Apr 2019 11:04:41 +0100 Subject: [PATCH] Fix add component bug where transform parent could not be found by index --- nexus_constructor/qml_models/instrument_model.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/nexus_constructor/qml_models/instrument_model.py b/nexus_constructor/qml_models/instrument_model.py index 44be939fc..1a011d798 100644 --- a/nexus_constructor/qml_models/instrument_model.py +++ b/nexus_constructor/qml_models/instrument_model.py @@ -324,7 +324,17 @@ def update_child_transforms(self, component): @Slot(int, result="QVariant") def get_transform_model(self, index: int): - return self.transform_models[index] + """ + Returns the transform model for the component. + The list is 1-based due to the 0 being no parent, so we have to use index-1 here + unless the component has no transform parent (for example the sample) + :param index: The component's transform parents index. + :return: The transform model for the component. + """ + if index == 0: + return self.transform_models[index] + else: + return self.transform_models[index - 1] @Slot(str, result=str) def generate_component_name(self, base):