Skip to content

Commit

Permalink
[StatusNotifier] Fix errors on finalising
Browse files Browse the repository at this point in the history
Suppression of `ValueError`s when finalising widget to prevent crashes.

Fixes elParaguayo/qtile-extras#370
  • Loading branch information
elParaguayo committed Aug 10, 2024
1 parent 441b437 commit 68d6bee
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions libqtile/widget/helpers/status_notifier/statusnotifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
from contextlib import suppress
from functools import partial
from pathlib import Path

Expand Down Expand Up @@ -689,13 +690,16 @@ def unregister_callbacks(
self, on_item_added=None, on_item_removed=None, on_icon_changed=None
):
if on_item_added is not None:
self._on_item_added.remove(on_item_added)
with suppress(ValueError):
self._on_item_added.remove(on_item_added)

if on_item_removed is not None:
self._on_item_removed.remove(on_item_removed)
with suppress(ValueError):
self._on_item_removed.remove(on_item_removed)

if on_icon_changed is not None:
self._on_icon_changed.remove(on_icon_changed)
with suppress(ValueError):
self._on_icon_changed.remove(on_icon_changed)


host = StatusNotifierHost() # noqa: E303

0 comments on commit 68d6bee

Please sign in to comment.