From 476fb2f65e8f3e016d7a904f1c8e25409d541ef1 Mon Sep 17 00:00:00 2001 From: krzywon Date: Thu, 28 Jan 2021 17:34:20 -0500 Subject: [PATCH 1/3] Fix project load issue involving 3+ fit tabs. --- src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py b/src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py index e7e10d4539..ca4043085e 100644 --- a/src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py +++ b/src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py @@ -409,9 +409,10 @@ def setData(self, data_item=None, is_batch=False, tab_index=None): # Find the first unassigned tab. # If none, open a new tab. available_tabs = [tab.acceptsData() for tab in self.tabs] + tab_ids = [tab.tab_id for tab in self.tabs] if tab_index is not None: - if tab_index >= self.maxIndex: + if tab_index not in tab_ids: self.addFit(data, is_batch=is_batch, tab_index=tab_index) else: self.setCurrentIndex(tab_index-1) From 2d622a99c94a06841a465d8188e9ec479cc9361e Mon Sep 17 00:00:00 2001 From: krzywon Date: Fri, 29 Jan 2021 08:13:28 -0500 Subject: [PATCH 2/3] Ensure maxIndex is always the larger than the known tab id numbers. --- src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py b/src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py index ca4043085e..1990d6fbc6 100644 --- a/src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py +++ b/src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py @@ -247,7 +247,7 @@ def addFit(self, data, is_batch=False, tab_index=None): self.tabs.append(tab) if data: self.updateFitDict(data, tab_name) - self.maxIndex = tab_index + 1 + self.maxIndex = max([tab.tab_id for tab in self.tabs]) + 1 icon = QtGui.QIcon() if is_batch: From 1007acbdb1f4c3f1b4dc73196f805db2aa19cd97 Mon Sep 17 00:00:00 2001 From: krzywon Date: Fri, 29 Jan 2021 11:28:04 -0500 Subject: [PATCH 3/3] Add default value for max() as a fallback. --- src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py b/src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py index 1990d6fbc6..33d084e79f 100644 --- a/src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py +++ b/src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py @@ -247,7 +247,7 @@ def addFit(self, data, is_batch=False, tab_index=None): self.tabs.append(tab) if data: self.updateFitDict(data, tab_name) - self.maxIndex = max([tab.tab_id for tab in self.tabs]) + 1 + self.maxIndex = max([tab.tab_id for tab in self.tabs], default=0) + 1 icon = QtGui.QIcon() if is_batch: