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
|
waitForSync = True
|
||||||
elif reply == QtGui.QMessageBox.Cancel:
|
elif reply == QtGui.QMessageBox.Cancel:
|
||||||
return
|
return
|
||||||
|
else:
|
||||||
|
Missing().stop()
|
||||||
|
|
||||||
if shared.statusIconColor == 'red':
|
if shared.statusIconColor == 'red':
|
||||||
reply = QtGui.QMessageBox.question(self, _translate("MainWindow", "Not connected"),
|
reply = QtGui.QMessageBox.question(self, _translate("MainWindow", "Not connected"),
|
||||||
|
|
|
@ -90,8 +90,11 @@ class Missing(object):
|
||||||
super(self.__class__, self).__init__()
|
super(self.__class__, self).__init__()
|
||||||
self.lock = RLock()
|
self.lock = RLock()
|
||||||
self.hashes = {}
|
self.hashes = {}
|
||||||
|
self.stopped = False
|
||||||
|
|
||||||
def add(self, objectHash):
|
def add(self, objectHash):
|
||||||
|
if self.stopped:
|
||||||
|
return
|
||||||
with self.lock:
|
with self.lock:
|
||||||
if not objectHash in self.hashes:
|
if not objectHash in self.hashes:
|
||||||
self.hashes[objectHash] = {'peers':[], 'requested':0}
|
self.hashes[objectHash] = {'peers':[], 'requested':0}
|
||||||
|
@ -105,6 +108,8 @@ class Missing(object):
|
||||||
with self.lock:
|
with self.lock:
|
||||||
try:
|
try:
|
||||||
self.hashes[objectHash]['peers'].remove(current_thread().peer)
|
self.hashes[objectHash]['peers'].remove(current_thread().peer)
|
||||||
|
except KeyError:
|
||||||
|
return
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
if len(self.hashes[objectHash]['peers']) == 0:
|
if len(self.hashes[objectHash]['peers']) == 0:
|
||||||
|
@ -131,6 +136,10 @@ class Missing(object):
|
||||||
if objectHash in self.hashes:
|
if objectHash in self.hashes:
|
||||||
del self.hashes[objectHash]
|
del self.hashes[objectHash]
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
with self.lock:
|
||||||
|
self.hashes = {}
|
||||||
|
|
||||||
def threadEnd(self):
|
def threadEnd(self):
|
||||||
with self.lock:
|
with self.lock:
|
||||||
for objectHash in self.hashes:
|
for objectHash in self.hashes:
|
||||||
|
|
Reference in New Issue
Block a user