@@ -46,6 +46,15 @@ def __init__(self, account, password, *args, **kwargs):
46
46
super (LoginThread , self ).__init__ (* args , ** kwargs )
47
47
self .account = account
48
48
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' )
49
58
50
59
@classmethod
51
60
def start (cls , account , password , parent = None ):
@@ -54,11 +63,6 @@ def start(cls, account, password, parent=None):
54
63
:param account: 账号
55
64
:param password: 密码
56
65
"""
57
- if hasattr (cls , '_thread' ):
58
- cls ._thread .quit ()
59
- cls ._thread .wait (1000 )
60
- cls ._thread .deleteLater ()
61
- AppLog .info ('login thread killed' )
62
66
cls ._thread = QThread (parent )
63
67
cls ._worker = LoginThread (account , password )
64
68
cls ._worker .moveToThread (cls ._thread )
@@ -105,11 +109,13 @@ def run(self):
105
109
Signals .loginErrored .emit (QCoreApplication .translate (
106
110
'Repository' , 'Incorrect account or password' ))
107
111
AppLog .warn ('Incorrect account or password' )
112
+ LoginThread .quit ()
108
113
return
109
114
if 'login' not in retval :
110
115
Signals .loginErrored .emit (QCoreApplication .translate (
111
116
'Repository' , 'Login failed, Unknown reason' ))
112
117
AppLog .warn ('Login failed, Unknown reason' )
118
+ LoginThread .quit ()
113
119
return
114
120
# 用户ID
115
121
uid = retval .get ('id' , 0 )
@@ -137,6 +143,7 @@ def run(self):
137
143
AppLog .exception (e )
138
144
139
145
AppLog .info ('login thread end' )
146
+ LoginThread .quit ()
140
147
141
148
142
149
class ProgressCallback (RemoteCallbacks ):
@@ -155,6 +162,15 @@ class CloneThread(QObject):
155
162
"""
156
163
157
164
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' )
158
174
159
175
@classmethod
160
176
def start (cls , parent = None ):
@@ -263,6 +279,7 @@ def run(self):
263
279
AppLog .info ('clone thread end' )
264
280
Signals .progressStoped .emit ()
265
281
Signals .cloneFinished .emit ('' )
282
+ CloneThread .quit ()
266
283
267
284
268
285
class UpgradeThread (QObject ):
@@ -274,6 +291,15 @@ class UpgradeThread(QObject):
274
291
275
292
# Url = 'https://raw.githubusercontent.com/IronyYou/test/master/Update/Upgrade.json'
276
293
# 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' )
277
303
278
304
@classmethod
279
305
def start (cls , parent = None ):
@@ -336,6 +362,7 @@ def run(self):
336
362
AppLog .info (req .text )
337
363
if req .status_code != 200 :
338
364
AppLog .info ('update thread end' )
365
+ UpgradeThread .quit ()
339
366
return
340
367
content = req .json ()
341
368
for version , text in content :
@@ -354,3 +381,4 @@ def run(self):
354
381
self .tr ('update failed: {}' ).format (str (e )))
355
382
AppLog .exception (e )
356
383
AppLog .info ('update thread end' )
384
+ UpgradeThread .quit ()
0 commit comments