Documenting a bug caused by changing the location of when certain signals are emitted
[gc-dialer] / src / session.py
index a445788..f0fb9cf 100644 (file)
@@ -85,11 +85,7 @@ class Draft(QtCore.QObject):
        def add_contact(self, contactId, title, description, numbersWithDescriptions):
                if self._busyReason is not None:
                        raise RuntimeError("Please wait for %r" % self._busyReason)
-               if contactId in self._contacts:
-                       _moduleLogger.info("Adding duplicate contact %r" % contactId)
-                       # @todo Remove this evil hack to re-popup the dialog
-                       self.recipientsChanged.emit()
-                       return
+               # Allow overwriting of contacts so that the message can be updated and the SMS dialog popped back up
                contactDetails = _DraftContact(title, description, numbersWithDescriptions)
                self._contacts[contactId] = contactDetails
                self.recipientsChanged.emit()
@@ -197,6 +193,7 @@ class Draft(QtCore.QObject):
 class Session(QtCore.QObject):
 
        # @todo Somehow add support for csv contacts
+       # @BUG When loading without caches, downloads messages twice
 
        stateChange = QtCore.pyqtSignal(str)
        loggedOut = QtCore.pyqtSignal()
@@ -359,10 +356,13 @@ class Session(QtCore.QObject):
                return self._dnd
 
        def get_account_number(self):
+               if self.state != self.LOGGEDIN_STATE:
+                       return ""
                return self._backend[0].get_account_number()
 
        def get_callback_numbers(self):
-               # @todo Remove evilness (might call is_authed which can block)
+               if self.state != self.LOGGEDIN_STATE:
+                       return {}
                return self._backend[0].get_callback_numbers()
 
        def get_callback_number(self):
@@ -502,13 +502,19 @@ class Session(QtCore.QObject):
                        _moduleLogger.exception("Weirdness loading")
                        return False
 
-               (
-                       version, build,
-                       contacts, contactUpdateTime,
-                       messages, messageUpdateTime,
-                       history, historyUpdateTime,
-                       dnd, callback
-               ) = dumpedData
+               try:
+                       (
+                               version, build,
+                               contacts, contactUpdateTime,
+                               messages, messageUpdateTime,
+                               history, historyUpdateTime,
+                               dnd, callback
+                       ) = dumpedData
+               except ValueError:
+                       _moduleLogger.exception("Upgrade/downgrade fun")
+                       return False
+               except:
+                       _moduleLogger.exception("Weirdlings")
 
                if misc_utils.compare_versions(
                        self._OLDEST_COMPATIBLE_FORMAT_VERSION,