Skip to content

Commit

Permalink
AddonManager: Fixed crash when quickly clicking through addons
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Oct 10, 2019
1 parent 97933a5 commit 77550e0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/Mod/AddonManager/AddonManager.py
Expand Up @@ -304,6 +304,11 @@ def show(self,idx):
# kill existing show worker (might still be busy loading images...)
if self.show_worker:
self.show_worker.exit()
self.show_worker.stopImageLoading()
# wait until the thread stops
while True:
if self.show_worker.isFinished():
break
self.show_worker = ShowWorker(self.repos, idx)
self.show_worker.info_label.connect(self.show_information)
self.show_worker.addon_repos.connect(self.update_repos)
Expand Down
11 changes: 10 additions & 1 deletion src/Mod/AddonManager/addonmanager_workers.py
Expand Up @@ -407,13 +407,20 @@ def run(self):

self.info_label.emit( message )
self.progressbar_show.emit(False)
self.mustLoadImages = True
l = self.loadImages( message, self.repos[self.idx][1], self.repos[self.idx][0])
if l:
self.info_label.emit( l )
self.stop = True

def stopImageLoading(self):

"this stops the image loading process and allow the thread to terminate earlier"

self.mustLoadImages = False

def loadImages(self,message,url,wbName):

"checks if the given page contains images and downloads them"

# QTextBrowser cannot display online images. So we download them
Expand All @@ -427,6 +434,8 @@ def loadImages(self,message,url,wbName):
if not os.path.exists(store):
os.makedirs(store)
for path in imagepaths:
if not self.mustLoadImages:
return None
origpath = path
if "?" in path:
# remove everything after the ?
Expand Down

0 comments on commit 77550e0

Please sign in to comment.