Fix threading related crash when using the ChooseFormatDialog

This commit is contained in:
Kovid Goyal 2010-02-11 09:28:23 -07:00
parent e0320e0765
commit 81f58b185a
3 changed files with 27 additions and 7 deletions

View File

@ -115,6 +115,9 @@
<property name="decimals">
<number>1</number>
</property>
<property name="maximum">
<double>200.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
@ -135,6 +138,9 @@
<property name="decimals">
<number>1</number>
</property>
<property name="maximum">
<double>200.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0">
@ -155,6 +161,9 @@
<property name="decimals">
<number>1</number>
</property>
<property name="maximum">
<double>200.000000000000000</double>
</property>
</widget>
</item>
<item row="3" column="0">
@ -175,6 +184,9 @@
<property name="decimals">
<number>1</number>
</property>
<property name="maximum">
<double>200.000000000000000</double>
</property>
</widget>
</item>
</layout>

View File

@ -12,7 +12,8 @@ class ChooseFormatDialog(QDialog, Ui_ChooseFormatDialog):
QDialog.__init__(self, window)
Ui_ChooseFormatDialog.__init__(self)
self.setupUi(self)
self.connect(self.formats, SIGNAL('activated(QModelIndex)'), lambda i: self.accept())
self.connect(self.formats, SIGNAL('activated(QModelIndex)'),
self.activated_slot)
self.msg.setText(msg)
for format in formats:
@ -20,6 +21,15 @@ class ChooseFormatDialog(QDialog, Ui_ChooseFormatDialog):
format.upper()))
self._formats = formats
self.formats.setCurrentRow(0)
self._format = None
def activated_slot(self, *args):
self.accept()
def format(self):
return self._formats[self.formats.currentRow()]
return self._format
def accept(self):
self._format = self._formats[self.formats.currentRow()]
return QDialog.accept(self)

View File

@ -337,7 +337,8 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
QObject.connect(self.view_menu.actions()[0],
SIGNAL("triggered(bool)"), self.view_book)
QObject.connect(self.view_menu.actions()[1],
SIGNAL("triggered(bool)"), self.view_specific_format)
SIGNAL("triggered(bool)"), self.view_specific_format,
Qt.QueuedConnection)
self.connect(self.action_open_containing_folder,
SIGNAL('triggered(bool)'), self.view_folder)
self.delete_menu.actions()[0].triggered.connect(self.delete_books)
@ -1642,12 +1643,9 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
row = rows[0].row()
formats = self.library_view.model().db.formats(row).upper().split(',')
d = ChooseFormatDialog(self, _('Choose the format to view'), formats)
d.exec_()
if d.result() == QDialog.Accepted:
if d.exec_() == QDialog.Accepted:
format = d.format()
self.view_format(row, format)
else:
return
def view_folder(self, *args):
rows = self.current_view().selectionModel().selectedRows()