facelessuser / ColorHelper

Sublime plugin that provides helpful color previews and tooltips
https://facelessuser.github.io/ColorHelper/
MIT License
254 stars 30 forks source link

AttributeError when running `color_helper_preview` command #254

Closed deathaxe closed 1 year ago

deathaxe commented 1 year ago

Description

Every here and then ColorHelper throws the following exception - most likely after multiple packages have been upgraded by Package Control. But also saw it in other situations, when quickly closing views (e.g.: while previewing them).

Traceback (most recent call last):
  File "<ST>\Lib\python33\sublime_plugin.py", line 944, in on_activated_async
    run_view_callbacks('on_activated_async', view_id)
  File "<ST>\Lib\python33\sublime_plugin.py", line 708, in run_view_callbacks
    callback(v, *args)
  File "<ST>\Lib\python33\sublime_plugin.py", line 190, in exception_handler
    return event_handler(*args)
  File "<ST>\Data\Installed Packages\ColorHelper.sublime-package\ch_preview.py", line 682, in on_activated_async
    view.window().run_command('color_helper_preview', {"clear": False, "force": True})
AttributeError: 'NoneType' object has no attribute 'run_command'

Note: As of Package Control 4.0 packages are re-enabled all together after upgrade. As I haven't checked whether it happens with PC 3.4.1 as well, I am uncertain about any relations. I also don't see any views being opened or closed while upgrading. LSP destroys and creates output panels during upgrading - may those be involved?

Support Info

Steps to Reproduce Issue

  1. Maybe install Package Control 4.0-beta (uncertain whether it is related)
  2. Wait for or force multiple packages to be updated
    (e.g.: LSP and various of its LSP-helper packages, various others should do so, too)
facelessuser commented 1 year ago

I am not currently using Package Control 4.0 beta, and I am uncertain how to upgrade to 4.0 beta.

With that said, the issue seems it may not be specific to PC 4 beta. The problem seems that every once in a while view.window() is not returning a window. This is most likely a race condition with the recent change to use on_activated_async. Worst case is that we back out that change until we can better ensure this race condition does not happen.

facelessuser commented 1 year ago

It seems I added the on_activated_async instead of on_activated to fix some regression that I am no longer able to reproduce when using just on_activated. I will remove the on_activated_async call. Hopefully that will fix the issue.

facelessuser commented 1 year ago

Closing this with commit https://github.com/facelessuser/ColorHelper/commit/ab7925d0b7935f1b119744e016807b081ab868f5. If this issue persists after the update, or others are discovered, feel free to reopen or open a new issue.