SublimeANSI icon indicating copy to clipboard operation
SublimeANSI copied to clipboard

Fix race condition leading to AttributeError

Open giampaolo opened this issue 1 year ago • 1 comments

Hello @aziz.

I've seen this error multiple times over the months (years?), without ever being able to come up with a reproducing test case. It just shows up from time to time. Long story short: these 2 lines check whether window is not None: https://github.com/aziz/SublimeANSI/blob/master/ansi.py#L373-L374. Window may not be None at line 373, but it can turn to None at lines 375 and 377 (this is the race condition). The error that can be seen in ST console is:

  File "/home/giampaolo/.config/sublime-text/Installed Packages/ANSIescape.sublime-package/ansi.py", line 343, in check_left_ansi
    if not self._is_view_valid(view):
  File "/home/giampaolo/.config/sublime-text/Installed Packages/ANSIescape.sublime-package/ansi.py", line 377, in _is_view_valid
    if view not in view.window().views():
AttributeError: 'NoneType' object has no attribute 'views'

giampaolo avatar Dec 26 '23 15:12 giampaolo

I now realize this is a very old issue for which a solution has been proposed already (but unfortunately no merge): https://github.com/aziz/SublimeANSI/issues/43 https://github.com/aziz/SublimeANSI/issues/12

giampaolo avatar Dec 26 '23 15:12 giampaolo