pyinat/naturtag

Gracefully cancel running threadpool tasks

Opened this issue · 0 comments

Currently, using QThreadPool, it appears that there's not a built-in way to cancel running tasks. This will require some kind of custom sentinel value on each worker.

When tasks continue to run when they're no longer needed (e.g., user has navigated to a different taxon before the previous one has completed loading), this results in errors (RuntimeError: Internal C++ object (PixmapLabel) already deleted.. The thread has loaded an image and returned it to the main thread, which then attempts to update the UI, but the object has already been garbage collected because it no longer belongs to a parent widget.