diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index 4cdcae30..04562fe6 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -2721,6 +2721,8 @@ class MyForm(settingsmixin.SMainWindow): waitForSync = True elif reply == QtGui.QMessageBox.Cancel: return + else: + Missing().stop() if shared.statusIconColor == 'red': reply = QtGui.QMessageBox.question(self, _translate("MainWindow", "Not connected"), diff --git a/src/inventory.py b/src/inventory.py index 77291a5c..0e81e756 100644 --- a/src/inventory.py +++ b/src/inventory.py @@ -90,8 +90,11 @@ class Missing(object): super(self.__class__, self).__init__() self.lock = RLock() self.hashes = {} + self.stopped = False def add(self, objectHash): + if self.stopped: + return with self.lock: if not objectHash in self.hashes: self.hashes[objectHash] = {'peers':[], 'requested':0} @@ -105,6 +108,8 @@ class Missing(object): with self.lock: try: self.hashes[objectHash]['peers'].remove(current_thread().peer) + except KeyError: + return except ValueError: pass if len(self.hashes[objectHash]['peers']) == 0: @@ -131,6 +136,10 @@ class Missing(object): if objectHash in self.hashes: del self.hashes[objectHash] + def stop(self): + with self.lock: + self.hashes = {} + def threadEnd(self): with self.lock: for objectHash in self.hashes: