Repository: qutebrowser/qutebrowser

Issue:
Remove unneeded changed signals with new completion
For example, `UrlMarkManager` has `added`, `removed` and `changed` signals - are they still needed with the new completion? There might be more too...

cc @rcorre 


Discussion:

Resolving patch:
diff --git a/qutebrowser/browser/urlmarks.py b/qutebrowser/browser/urlmarks.py
--- a/qutebrowser/browser/urlmarks.py
+++ b/qutebrowser/browser/urlmarks.py
@@ -77,13 +77,9 @@ class UrlMarkManager(QObject):
 
     Signals:
         changed: Emitted when anything changed.
-        added: Emitted when a new quickmark/bookmark was added.
-        removed: Emitted when an existing quickmark/bookmark was removed.
     """
 
     changed = pyqtSignal()
-    added = pyqtSignal(str, str)
-    removed = pyqtSignal(str)
 
     def __init__(self, parent=None):
         """Initialize and read quickmarks."""
@@ -121,7 +117,6 @@ def delete(self, key):
         """
         del self.marks[key]
         self.changed.emit()
-        self.removed.emit(key)
 
 
 class QuickmarkManager(UrlMarkManager):
@@ -133,7 +128,6 @@ class QuickmarkManager(UrlMarkManager):
         - self.marks maps names to URLs.
         - changed gets emitted with the name as first argument and the URL as
           second argument.
-        - removed gets emitted with the name as argument.
     """
 
     def _init_lineparser(self):
@@ -193,7 +187,6 @@ def set_mark():
             """Really set the quickmark."""
             self.marks[name] = url
             self.changed.emit()
-            self.added.emit(name, url)
             log.misc.debug("Added quickmark {} for {}".format(name, url))
 
         if name in self.marks:
@@ -243,7 +236,6 @@ class BookmarkManager(UrlMarkManager):
         - self.marks maps URLs to titles.
         - changed gets emitted with the URL as first argument and the title as
           second argument.
-        - removed gets emitted with the URL as argument.
     """
 
     def _init_lineparser(self):
@@ -295,5 +287,4 @@ def add(self, url, title, *, toggle=False):
         else:
             self.marks[urlstr] = title
             self.changed.emit()
-            self.added.emit(title, urlstr)
             return True
diff --git a/qutebrowser/misc/sessions.py b/qutebrowser/misc/sessions.py
--- a/qutebrowser/misc/sessions.py
+++ b/qutebrowser/misc/sessions.py
@@ -23,7 +23,7 @@
 import os.path
 
 import sip
-from PyQt5.QtCore import pyqtSignal, QUrl, QObject, QPoint, QTimer
+from PyQt5.QtCore import QUrl, QObject, QPoint, QTimer
 from PyQt5.QtWidgets import QApplication
 import yaml
 try:
@@ -106,14 +106,8 @@ class SessionManager(QObject):
                               closed.
         _current: The name of the currently loaded session, or None.
         did_load: Set when a session was loaded.
-
-    Signals:
-        update_completion: Emitted when the session completion should get
-                           updated.
     """
 
-    update_completion = pyqtSignal()
-
     def __init__(self, base_path, parent=None):
         super().__init__(parent)
         self._current = None
@@ -303,8 +297,7 @@ def save(self, name, last_window=False, load_next_time=False,
                           encoding='utf-8', allow_unicode=True)
         except (OSError, UnicodeEncodeError, yaml.YAMLError) as e:
             raise SessionError(e)
-        else:
-            self.update_completion.emit()
+
         if load_next_time:
             state_config = objreg.get('state-config')
             state_config['general']['session'] = name
@@ -425,7 +418,6 @@ def delete(self, name):
             os.remove(path)
         except OSError as e:
             raise SessionError(e)
-        self.update_completion.emit()
 
     def list_sessions(self):
         """Get a list of all session names."""


Test patch:
diff --git a/tests/unit/misc/test_sessions.py b/tests/unit/misc/test_sessions.py
--- a/tests/unit/misc/test_sessions.py
+++ b/tests/unit/misc/test_sessions.py
@@ -215,11 +215,6 @@ def set_data(items):
         objreg.delete('main-window', scope='window', window=0)
         objreg.delete('tabbed-browser', scope='window', window=0)
 
-    def test_update_completion_signal(self, sess_man, tmpdir, qtbot):
-        session_path = tmpdir / 'foo.yml'
-        with qtbot.waitSignal(sess_man.update_completion):
-            sess_man.save(str(session_path))
-
     def test_no_state_config(self, sess_man, tmpdir, state_config):
         session_path = tmpdir / 'foo.yml'
         sess_man.save(str(session_path))
@@ -367,14 +362,6 @@ def test_urls(self, sess_man, fake_webview, original_url):
         assert loaded_item.original_url == expected
 
 
-def test_delete_update_completion_signal(sess_man, qtbot, tmpdir):
-    sess = tmpdir / 'foo.yml'
-    sess.ensure()
-
-    with qtbot.waitSignal(sess_man.update_completion):
-        sess_man.delete(str(sess))
-
-
 class TestListSessions:
 
     def test_no_sessions(self, tmpdir):