Browse Source

Fix close while downloading error

doc-issue-template
MrS0m30n3 10 years ago
parent
commit
9f252a486a
2 changed files with 9 additions and 3 deletions
  1. 9
      youtube_dl_gui/DownloadThread.py
  2. 3
      youtube_dl_gui/YoutubeDLGUI.py

9
youtube_dl_gui/DownloadThread.py

@ -33,6 +33,7 @@ class DownloadManager(Thread):
self.logmanager = logmanager
self.options = options
self.running = True
self.kill = False
self.procList = []
self.procNo = 0
self.start()
@ -69,7 +70,8 @@ class DownloadManager(Thread):
sleep(0.1)
# If we reach here close down all child threads
self.terminate_all()
CallAfter(Publisher.sendMessage, PUBLISHER_TOPIC, DataPack('finish'))
if not self.kill:
CallAfter(Publisher.sendMessage, PUBLISHER_TOPIC, DataPack('finish'))
def downloading(self):
for proc in self.procList:
@ -98,8 +100,9 @@ class DownloadManager(Thread):
if not proc.isAlive():
return proc
return None
def close(self):
def close(self, kill=False):
self.kill = kill
self.procNo = 0
self.running = False
CallAfter(Publisher.sendMessage, PUBLISHER_TOPIC, DataPack('close'))

3
youtube_dl_gui/YoutubeDLGUI.py

@ -288,6 +288,9 @@ class MainFrame(wx.Frame):
optionsFrame.Show()
def OnClose(self, event):
if self.downloadThread != None:
self.downloadThread.close(kill=True)
self.downloadThread.join()
self.save_options()
self.Destroy()

Loading…
Cancel
Save