Make sorting robust against tweak_fmt_order

This commit is contained in:
Kovid Goyal 2025-02-28 16:06:42 +05:30
parent ed866257df
commit 7f4487d318
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -110,7 +110,12 @@ class TweakEpubAction(InterfaceActionWithLibraryDrop):
tprefs.refresh() # In case they were changed in a Tweak Book process
if len(tweakable_fmts) > 1:
if tprefs['choose_tweak_fmt']:
d = Choose(title, sorted(tweakable_fmts, key=tprefs.defaults['tweak_fmt_order'].index), self.gui)
def index(x):
try:
return tprefs.defaults['tweak_fmt_order'].index(x)
except Exception:
return len(tprefs.defaults['tweak_fmt_order'])
d = Choose(title, sorted(tweakable_fmts, key=index), self.gui)
if d.exec() != QDialog.DialogCode.Accepted:
return
tweakable_fmts = {d.fmt}