Skip to content
Open
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions src/napari_plugin_manager/_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ def raise_on_call(*_, **__):
monkeypatch.setattr(QDialog, 'exec_', raise_on_call)


@pytest.fixture(autouse=True)
def _disable_generator_worker(monkeypatch, request):
if 'enable_generator_worker' not in request.keywords:
# Replace GeneratorWorker.start with GeneratorWorker.run to make it synchronous
from napari._qt.qthreading import GeneratorWorker

monkeypatch.setattr(GeneratorWorker, 'start', GeneratorWorker.run)


if TYPE_CHECKING:
from virtualenv.run import Session

Expand Down
21 changes: 14 additions & 7 deletions src/napari_plugin_manager/base_qt_plugin_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
QKeySequence,
QMovie,
QShortcut,
QShowEvent,
)
from qtpy.QtWidgets import (
QCheckBox,
Expand Down Expand Up @@ -1073,13 +1074,6 @@ def __init__(self, parent: QDialog = None, prefix=None) -> None:
self.installer.allFinished.connect(self._on_installer_all_finished)
self.setAcceptDrops(True)

if (
parent is not None and parent._plugin_dialog is self
) or parent is None:
self.refresh()
self._setup_shortcuts()
self._setup_theme_update()

# region - Private methods
# ------------------------------------------------------------------------
def _enable_refresh_button(self) -> None:
Expand Down Expand Up @@ -1765,6 +1759,15 @@ def exec_(self) -> None:
self._update_theme(None)
self._first_open = False

def showEvent(self, event: QShowEvent) -> None:
super().showEvent(event)
if (
self.parent() is not None and self.parent()._plugin_dialog is self
) or self.parent() is None:
self.refresh()
self._setup_shortcuts()
self._setup_theme_update()

def hideEvent(self, event: QHideEvent) -> None:
if len(self.modified_set):
# At least one plugin was installed, uninstalled or updated so
Expand All @@ -1774,6 +1777,10 @@ def hideEvent(self, event: QHideEvent) -> None:
RestartWarningDialog(self).exec_()
self.packages_search.clear()
self.toggle_status(False)
if self.worker is not None and self.worker.is_running:
self.worker.terminate()
self.worker.wait()
self.worker = None
Comment on lines +1780 to +1783
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will cancel ongoing tasks, right? That would go against the idea of background tasks in #174

super().hideEvent(event)

# endregion - Qt overrides
Expand Down
Loading