Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not try to remove item if already deleted #1498

Merged
merged 2 commits into from
Sep 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions sleap/gui/overlays/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,22 @@
so that current frame must be redrawn).
"""

from qtpy import QtWidgets

import attr
import abc
import numpy as np
import logging
from typing import Sequence, Union, Optional, List

import attr
import numpy as np
from qtpy import QtWidgets
from qtpy.QtWidgets import QGraphicsItem

from sleap import Labels, Video
from sleap.gui.widgets.video import QtVideoPlayer
from sleap.nn.data.providers import VideoReader
from sleap.nn.inference import VisualPredictor

logger = logging.getLogger(__name__)


@attr.s(auto_attribs=True)
class BaseOverlay(abc.ABC):
Expand Down Expand Up @@ -64,7 +66,15 @@ def remove_from_scene(self):
if self.items is None:
return
for item in self.items:
self.player.scene.removeItem(item)
try:
self.player.scene.removeItem(item)

except RuntimeError as e: # Internal C++ object (PySide2.QtWidgets.QGraphicsPathItem) already deleted.
logger.debug(e)
pass

# Stop tracking the items after they been removed from the scene
self.items = []

def redraw(self, video, frame_idx, *args, **kwargs):
"""Remove all items from the scene before adding new items to the scene.
Expand Down