ncssar / radiolog

SAR radio log program
Other
13 stars 3 forks source link

error during updateTeamTimers due to missing spacers between tab groups #689

Closed caver456 closed 8 months ago

caver456 commented 8 months ago

this error repeats every second, after a team is created that would be in a different tab group, generating a spacer:

Traceback (most recent call last):
  File "C:\Users\caver\Documents\GitHub\radiolog\radiolog.py", line 3814, in updateTeamTimers
    self.ui.tabWidget.tabBar().tabButton(i,QTabBar.LeftSide).setStyleSheet(statusStyleDict[status])
AttributeError: 'NoneType' object has no attribute 'setStyleSheet'

Either the index variable i doesn't account for spacers, or, the spacer is not getting generated correctly.

caver456 commented 8 months ago

This error was discovered during work on #683, which is being done in a separate branch. A few findings:

After 'SAR 1' added: image

Then, after 'Team 1' added - the gap is missing and the error begins: image

In the opposite sequence, after 'Team 1' added first then 'SAR 1' added second - which doesn't cause the error: image

Should probably check for related team tab grouping issues - more than two groups, variation on whether the new tab group would be to the left or the right of the existing tab group, etc.

caver456 commented 8 months ago

It does look like this might happen whenever a newly added tab group (i.e. a tab is added that will trigger creation of a new tab group) should be to the left of an existing group, the error begins; but a newly added tab group that should be to the right of all existing groups doesn't trigger the error.

Note that there are only two tab groups in the default tabGroups setting, so, testing this required use of a more complicated tabGroups setting. Used the example tabGroups setting from radiolog.cfg.

Example: first 1p23, second SAR 1 (no error yet), third Team 1 (this starts the error, and the missing spacer): image

caver456 commented 8 months ago

After tkdiffing and testing, the error is due to this section of code:

        self.rebuildGroupedTabDict()
        rprint("extTeamNameList after sort:"+str(self.extTeamNameList))
        if not self.loadFlag:
            # 670 - for the first team of a new session, and when unhiding the only tab
            #  (due to display issues noted in https://github.com/ncssar/radiolog/issues/670#issuecomment-1712814526)
            #  follow the old behavior and rebuild the entire tab bar;
            #  for subsequent teams, only add the tab for the new team 
            if self.ui.tabWidget.tabBar().count()<2:
                self.rebuildTabs()
            else:
                # display issues when unhiding the rightmost tab
                #  https://github.com/ncssar/radiolog/issues/670#issuecomment-1712814526
                # so, if this would be the rightmost tab, activate a different tab first
                self.ui.tabWidget.tabBar().setCurrentIndex(0)
                self.addTab(extTeamName)

versus the previous version that didn't cause the error but led to slowness (see #670):

        self.rebuildGroupedTabDict()
        rprint("extTeamNameList after sort:"+str(self.extTeamNameList))
        if not self.loadFlag:
            self.rebuildTabs()