Commit 10feb8b6 authored by Steve Borho's avatar Steve Borho
Browse files

guess: more robust canceling of search thread

This dialog could use a stop button, but at least ESC will safely
stop the search without causing a thread lockup.
parent fdc0f4e1f364
......@@ -249,11 +249,9 @@ class DetectRenameDialog(QDialog):
def reject(self):
if self.thread and self.thread.isRunning():
# This can lockup, so stop waiting after 2sec
self.thread.wait( 2000 )
self.thread = None
if self.thread.wait(2000):
self.thread = None
s = QSettings()
s.setValue('guess/geom', self.saveGeometry())
......@@ -354,6 +352,7 @@ class RenameSearchThread(QThread):
self.ufiles = ufiles
self.minpct = minpct
self.copies = copies
self.stopped = False
def run(self):
def emit(topic, pos, item='', unit='', total=None):
......@@ -364,6 +363,9 @@ class RenameSearchThread(QThread):
except Exception, e:
def cancel(self):
self.stopped = True
def search(self, repo):
wctx = repo[None]
pctx = repo['.']
......@@ -381,6 +383,8 @@ class RenameSearchThread(QThread):
exacts = []
gen = similar._findexactmatches(repo, added, removed)
for o, n in gen:
if self.stopped:
old, new = o.path(), n.path()
self.match.emit([old, new, '100%'])
......@@ -389,6 +393,8 @@ class RenameSearchThread(QThread):
removed = [r for r in removed if r.path() not in exacts]
gen = similar._findsimilarmatches(repo, added, removed, self.minpct)
for o, n, s in gen:
if self.stopped:
old, new, sim = o.path(), n.path(), '%d%%' % (s*100)
self.match.emit([old, new, sim])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment