Make objects to be send stoppable if not empty
This commit is contained in:
parent
94f0bdc731
commit
805f72e098
|
@ -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"),
|
||||
|
|
|
@ -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:
|
||||
|
|
Reference in New Issue
Block a user