@@ -46,6 +46,15 @@ def __init__(self, account, password, *args, **kwargs):
4646 super (LoginThread , self ).__init__ (* args , ** kwargs )
4747 self .account = account
4848 self .password = password
49+
50+ @classmethod
51+ def quit (cls ):
52+ """退出线程
53+ :param cls:
54+ """
55+ if hasattr (cls , '_thread' ):
56+ cls ._thread .quit ()
57+ AppLog .info ('login thread quit' )
4958
5059 @classmethod
5160 def start (cls , account , password , parent = None ):
@@ -54,11 +63,6 @@ def start(cls, account, password, parent=None):
5463 :param account: 账号
5564 :param password: 密码
5665 """
57- if hasattr (cls , '_thread' ):
58- cls ._thread .quit ()
59- cls ._thread .wait (1000 )
60- cls ._thread .deleteLater ()
61- AppLog .info ('login thread killed' )
6266 cls ._thread = QThread (parent )
6367 cls ._worker = LoginThread (account , password )
6468 cls ._worker .moveToThread (cls ._thread )
@@ -105,11 +109,13 @@ def run(self):
105109 Signals .loginErrored .emit (QCoreApplication .translate (
106110 'Repository' , 'Incorrect account or password' ))
107111 AppLog .warn ('Incorrect account or password' )
112+ LoginThread .quit ()
108113 return
109114 if 'login' not in retval :
110115 Signals .loginErrored .emit (QCoreApplication .translate (
111116 'Repository' , 'Login failed, Unknown reason' ))
112117 AppLog .warn ('Login failed, Unknown reason' )
118+ LoginThread .quit ()
113119 return
114120 # 用户ID
115121 uid = retval .get ('id' , 0 )
@@ -137,6 +143,7 @@ def run(self):
137143 AppLog .exception (e )
138144
139145 AppLog .info ('login thread end' )
146+ LoginThread .quit ()
140147
141148
142149class ProgressCallback (RemoteCallbacks ):
@@ -155,6 +162,15 @@ class CloneThread(QObject):
155162 """
156163
157164 Url = 'git://github.com/PyQt5/PyQt.git'
165+
166+ @classmethod
167+ def quit (cls ):
168+ """退出线程
169+ :param cls:
170+ """
171+ if hasattr (cls , '_thread' ):
172+ cls ._thread .quit ()
173+ AppLog .info ('clone thread quit' )
158174
159175 @classmethod
160176 def start (cls , parent = None ):
@@ -263,6 +279,7 @@ def run(self):
263279 AppLog .info ('clone thread end' )
264280 Signals .progressStoped .emit ()
265281 Signals .cloneFinished .emit ('' )
282+ CloneThread .quit ()
266283
267284
268285class UpgradeThread (QObject ):
@@ -274,6 +291,15 @@ class UpgradeThread(QObject):
274291
275292# Url = 'https://raw.githubusercontent.com/IronyYou/test/master/Update/Upgrade.json'
276293# ZipUrl = 'https://raw.githubusercontent.com/IronyYou/test/master/Update/Upgrade.{}.zip'
294+
295+ @classmethod
296+ def quit (cls ):
297+ """退出线程
298+ :param cls:
299+ """
300+ if hasattr (cls , '_thread' ):
301+ cls ._thread .quit ()
302+ AppLog .info ('upgrade thread quit' )
277303
278304 @classmethod
279305 def start (cls , parent = None ):
@@ -336,6 +362,7 @@ def run(self):
336362 AppLog .info (req .text )
337363 if req .status_code != 200 :
338364 AppLog .info ('update thread end' )
365+ UpgradeThread .quit ()
339366 return
340367 content = req .json ()
341368 for version , text in content :
@@ -354,3 +381,4 @@ def run(self):
354381 self .tr ('update failed: {}' ).format (str (e )))
355382 AppLog .exception (e )
356383 AppLog .info ('update thread end' )
384+ UpgradeThread .quit ()
0 commit comments