mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-11 09:13:57 -04:00
Keep references to BookInfo to prevent object lifetime issues
This commit is contained in:
parent
89c712128e
commit
4ce6bb4378
@ -5,6 +5,7 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
from PyQt4.Qt import Qt
|
||||
|
||||
from calibre.gui2.actions import InterfaceAction
|
||||
from calibre.gui2.dialogs.book_info import BookInfo
|
||||
@ -20,6 +21,7 @@ class ShowBookDetailsAction(InterfaceAction):
|
||||
|
||||
def genesis(self):
|
||||
self.qaction.triggered.connect(self.show_book_info)
|
||||
self.memory = []
|
||||
|
||||
def show_book_info(self, *args):
|
||||
if self.gui.current_view() is not self.gui.library_view:
|
||||
@ -29,6 +31,16 @@ class ShowBookDetailsAction(InterfaceAction):
|
||||
return
|
||||
index = self.gui.library_view.currentIndex()
|
||||
if index.isValid():
|
||||
BookInfo(self.gui, self.gui.library_view, index,
|
||||
self.gui.book_details.handle_click).show()
|
||||
d = BookInfo(self.gui, self.gui.library_view, index,
|
||||
self.gui.book_details.handle_click)
|
||||
self.memory.append(d)
|
||||
d.closed.connect(self.closed, type=Qt.QueuedConnection)
|
||||
d.show()
|
||||
|
||||
def closed(self, d):
|
||||
try:
|
||||
d.closed.disconnect(self.closed)
|
||||
self.memory.remove(d)
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
|
@ -4,7 +4,7 @@ __copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
|
||||
from PyQt4.Qt import (QCoreApplication, QModelIndex, QTimer, Qt,
|
||||
from PyQt4.Qt import (QCoreApplication, QModelIndex, QTimer, Qt, pyqtSignal,
|
||||
QDialog, QPixmap, QIcon, QSize, QPalette, QShortcut, QKeySequence)
|
||||
|
||||
from calibre.gui2.dialogs.book_info_ui import Ui_BookInfo
|
||||
@ -14,6 +14,8 @@ from calibre.gui2.book_details import render_html
|
||||
|
||||
class BookInfo(QDialog, Ui_BookInfo):
|
||||
|
||||
closed = pyqtSignal(object)
|
||||
|
||||
def __init__(self, parent, view, row, link_delegate):
|
||||
QDialog.__init__(self, parent)
|
||||
Ui_BookInfo.__init__(self)
|
||||
@ -59,6 +61,11 @@ class BookInfo(QDialog, Ui_BookInfo):
|
||||
link = unicode(qurl.toString())
|
||||
self.link_delegate(link)
|
||||
|
||||
def done(self, r):
|
||||
ret = QDialog.done(self, r)
|
||||
self.closed.emit(self)
|
||||
return ret
|
||||
|
||||
def cover_changed(self, data):
|
||||
if self.current_row is not None:
|
||||
id_ = self.view.model().id(self.current_row)
|
||||
|
Loading…
x
Reference in New Issue
Block a user