Skip to content

Commit

Permalink
Make objects to be send stoppable if not empty
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterSurda committed Jan 15, 2017
1 parent 94f0bdc commit 805f72e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/bitmessageqt/__init__.py
Expand Up @@ -2721,6 +2721,8 @@ def quit(self):
waitForSync = True
elif reply == QtGui.QMessageBox.Cancel:
return
else:
Missing().stop()

if shared.statusIconColor == 'red':
reply = QtGui.QMessageBox.question(self, _translate("MainWindow", "Not connected"),
Expand Down
9 changes: 9 additions & 0 deletions src/inventory.py
Expand Up @@ -90,8 +90,11 @@ def __init__(self):
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}
Expand All @@ -105,6 +108,8 @@ def removeObjectFromCurrentThread(self, objectHash):
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:
Expand All @@ -131,6 +136,10 @@ def delete(self, objectHash):
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:
Expand Down

0 comments on commit 805f72e

Please sign in to comment.