From 9948d17edcf376062b62df902b58ec9866b17ffe Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 24 Nov 2023 18:19:08 +0530 Subject: [PATCH] Fix choosing a file without saving the dir not working on windows Apparently the data file button in the insert link tool for the comments editor is the only place this was noticed. --- src/calibre/gui2/comments_editor.py | 2 +- src/calibre/gui2/win_file_dialogs.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/calibre/gui2/comments_editor.py b/src/calibre/gui2/comments_editor.py index a30ecf8ff8..1fb889c31d 100644 --- a/src/calibre/gui2/comments_editor.py +++ b/src/calibre/gui2/comments_editor.py @@ -838,7 +838,7 @@ class EditorWidget(QTextEdit, LineEditECM): # {{{ is_image = q in {'jpeg', 'png', 'gif', 'webp'} d.treat_as_image.setChecked(is_image) if data_dir: - path = os.path.relpath(path, base) + path = os.path.relpath(path, base).replace(os.sep, '/') d.url.setText(path) b.clicked.connect(lambda: cf()) d.brdf = b = QPushButton(_('&Data file')) diff --git a/src/calibre/gui2/win_file_dialogs.py b/src/calibre/gui2/win_file_dialogs.py index b8b9007fd5..0a7a54b493 100644 --- a/src/calibre/gui2/win_file_dialogs.py +++ b/src/calibre/gui2/win_file_dialogs.py @@ -268,8 +268,7 @@ def choose_files(window, name, title, ans = run_file_dialog(window, title, allow_multiple=not select_only_single_file, initial_folder=initial_folder, file_types=file_types) if ans and not no_save_dir: dynamic.set(name, os.path.dirname(ans[0])) - return ans - return None + return ans or None def choose_images(window, name, title, select_only_single_file=True, formats=None):