diff --git a/picard/ui/mainwindow/__init__.py b/picard/ui/mainwindow/__init__.py index 7de0098b2..9178ffaac 100644 --- a/picard/ui/mainwindow/__init__.py +++ b/picard/ui/mainwindow/__init__.py @@ -163,7 +163,7 @@ class MainWindow(QtWidgets.QMainWindow, PreserveGeometry): self.tagger = QtCore.QCoreApplication.instance() self._is_wayland = self.tagger.is_wayland self.selected_objects = [] - self.ignore_selection_changes = IgnoreUpdatesContext(self.update_selection) + self.ignore_selection_changes = IgnoreUpdatesContext(on_exit=self.update_selection) self.toolbar = None self.player = None self.status_indicators = [] diff --git a/picard/ui/metadatabox.py b/picard/ui/metadatabox.py index 1efadc6e2..a5bb31f99 100644 --- a/picard/ui/metadatabox.py +++ b/picard/ui/metadatabox.py @@ -276,7 +276,7 @@ class MetadataBox(QtWidgets.QTableWidget): self.preserved_tags = PreservedTags() self._single_file_album = False self._single_track_album = False - self.ignore_updates = IgnoreUpdatesContext(onexit=self.update) + self.ignore_updates = IgnoreUpdatesContext(on_exit=self.update) self.tagger.clipboard().dataChanged.connect(self._update_clipboard) def _get_file_lookup(self): diff --git a/picard/util/__init__.py b/picard/util/__init__.py index 9a2bfb0a8..ac295b7f0 100644 --- a/picard/util/__init__.py +++ b/picard/util/__init__.py @@ -561,17 +561,17 @@ class IgnoreUpdatesContext: updates if it is `False`. """ - def __init__(self, onexit=None): + def __init__(self, on_exit=None): self._entered = 0 - self._onexit = onexit + self._on_exit = on_exit def __enter__(self): self._entered += 1 def __exit__(self, type, value, tb): self._entered -= 1 - if self._onexit: - self._onexit() + if self._on_exit: + self._on_exit() def __bool__(self): return self._entered > 0 diff --git a/test/test_utils.py b/test/test_utils.py index ef3d7e4ac..ec762f509 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -923,12 +923,12 @@ class IgnoreUpdatesContextTest(PicardTestCase): self.assertTrue(context) self.assertFalse(context) - def test_run_onexit(self): - onexit = Mock() - context = IgnoreUpdatesContext(onexit=onexit) + def test_run_on_exit(self): + on_exit = Mock() + context = IgnoreUpdatesContext(on_exit=on_exit) with context: - onexit.assert_not_called() - onexit.assert_called_once_with() + on_exit.assert_not_called() + on_exit.assert_called_once_with() def test_nested_with(self): context = IgnoreUpdatesContext()