mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Linux: ToC Editor: Fix a regression in 7.17 that broke using the Create new entry button. Fixes #2085576 [Book editor crashes when adding new entry in ToC editor](https://bugs.launchpad.net/calibre/+bug/2085576)
Apparently as of Qt 6.7 having a webview in a dialog run with exec() breaks. So run the dialog with open() instead.
This commit is contained in:
parent
a961ddbfcb
commit
60a22179e9
@ -1194,13 +1194,15 @@ class TOCEditor(QDialog): # {{{
|
||||
|
||||
|
||||
def develop():
|
||||
from calibre.utils.webengine import setup_fake_protocol
|
||||
setup_fake_protocol()
|
||||
from calibre.gui2 import Application
|
||||
app = Application([])
|
||||
from calibre.utils.webengine import setup_default_profile, setup_fake_protocol
|
||||
setup_fake_protocol()
|
||||
setup_default_profile()
|
||||
d = TOCEditor(sys.argv[-1])
|
||||
d.start()
|
||||
d.exec()
|
||||
d.open()
|
||||
app.exec()
|
||||
del app
|
||||
|
||||
|
||||
@ -1234,9 +1236,10 @@ def main(shm_name=None):
|
||||
setup_default_profile()
|
||||
d = TOCEditor(path, title=title, write_result_to=path + '.result')
|
||||
d.start()
|
||||
ok = 0
|
||||
if d.exec() == QDialog.DialogCode.Accepted:
|
||||
ok = 1
|
||||
# Using d.exec() causes showing the webview to hide the dialog
|
||||
d.open()
|
||||
app.exec()
|
||||
ok = 1 if d.result() == QDialog.DialogCode.Accepted else 0
|
||||
s = struct.pack('>II', 2, ok)
|
||||
shm.seek(0), shm.write(s), shm.flush()
|
||||
|
||||
@ -1246,5 +1249,4 @@ def main(shm_name=None):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(path=sys.argv[-1], title='test')
|
||||
os.remove(sys.argv[-1] + '.lock')
|
||||
develop()
|
||||
|
@ -630,8 +630,14 @@ class Boss(QObject):
|
||||
if not self.ensure_book(_('You must open a book before trying to edit the Table of Contents.')):
|
||||
return
|
||||
self.add_savepoint(_('Before: Edit Table of Contents'))
|
||||
d = TOCEditor(title=self.current_metadata.title, parent=self.gui)
|
||||
if d.exec() != QDialog.DialogCode.Accepted:
|
||||
self.__current_toc_editor = d = TOCEditor(title=self.current_metadata.title, parent=self.gui)
|
||||
d.finished.connect(self.toc_edit_finished)
|
||||
# Using d.exec() causes showing the webview to hide the dialog
|
||||
d.open()
|
||||
|
||||
def toc_edit_finished(self, retcode: int):
|
||||
self.__current_toc_editor = None
|
||||
if retcode != QDialog.DialogCode.Accepted:
|
||||
self.rewind_savepoint()
|
||||
return
|
||||
with BusyCursor():
|
||||
|
Loading…
x
Reference in New Issue
Block a user