From 2bad2c5162157a9d5bc4bf85d0dc483540d9f85a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 16 May 2009 18:26:32 -0700 Subject: [PATCH] Fix #2449 (Crashing on mac os X 10.5.7 when cancel metadata search) --- src/calibre/gui2/dialogs/fetch_metadata.py | 2 ++ src/calibre/gui2/dialogs/metadata_single.py | 30 ++++++++++----------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/calibre/gui2/dialogs/fetch_metadata.py b/src/calibre/gui2/dialogs/fetch_metadata.py index 805cc1c3bf..62f26c757f 100644 --- a/src/calibre/gui2/dialogs/fetch_metadata.py +++ b/src/calibre/gui2/dialogs/fetch_metadata.py @@ -187,6 +187,8 @@ class FetchMetadata(QDialog, Ui_FetchMetadata): def terminate(self): if hasattr(self, 'fetcher') and self.fetcher.isRunning(): self.fetcher.terminate() + if hasattr(self, '_hangcheck') and self._hangcheck.isActive(): + self._hangcheck.stop() def __enter__(self, *args): diff --git a/src/calibre/gui2/dialogs/metadata_single.py b/src/calibre/gui2/dialogs/metadata_single.py index 5f2ea375b2..e5ee3bccca 100644 --- a/src/calibre/gui2/dialogs/metadata_single.py +++ b/src/calibre/gui2/dialogs/metadata_single.py @@ -419,22 +419,22 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog): publisher = qstring_to_unicode(self.publisher.currentText()) if isbn or title or author or publisher: d = FetchMetadata(self, isbn, title, author, publisher, self.timeout) + self._fetch_metadata_scope = d with d: - d.exec_() - if d.result() == QDialog.Accepted: - book = d.selected_book() - if book: - self.title.setText(book.title) - self.authors.setText(authors_to_string(book.authors)) - if book.author_sort: self.author_sort.setText(book.author_sort) - if book.publisher: self.publisher.setEditText(book.publisher) - if book.isbn: self.isbn.setText(book.isbn) - summ = book.comments - if summ: - prefix = qstring_to_unicode(self.comments.toPlainText()) - if prefix: - prefix += '\n' - self.comments.setText(prefix + summ) + if d.exec_() == QDialog.Accepted: + book = d.selected_book() + if book: + self.title.setText(book.title) + self.authors.setText(authors_to_string(book.authors)) + if book.author_sort: self.author_sort.setText(book.author_sort) + if book.publisher: self.publisher.setEditText(book.publisher) + if book.isbn: self.isbn.setText(book.isbn) + summ = book.comments + if summ: + prefix = qstring_to_unicode(self.comments.toPlainText()) + if prefix: + prefix += '\n' + self.comments.setText(prefix + summ) else: error_dialog(self, _('Cannot fetch metadata'), _('You must specify at least one of ISBN, Title, '