Skip to content
This repository was archived by the owner on Dec 18, 2019. It is now read-only.

Commit a5979a1

Browse files
committed
Doc date changing: Fix for Windows: Don't display the document will renaming its folder --> it keeps a file descriptor opened to its PDF file and prevent the renaming
Signed-off-by: Jerome Flesch <[email protected]>
1 parent 625ad84 commit a5979a1

File tree

1 file changed

+14
-5
lines changed
  • src/paperwork/frontend/mainwindow

1 file changed

+14
-5
lines changed

src/paperwork/frontend/mainwindow/docs.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,7 +1424,13 @@ def apply_properties(self):
14241424
if has_changed:
14251425
self.__main_win.upd_index({self.doc})
14261426
else:
1427-
old_doc = self.doc.clone()
1427+
self.doc.drop_cache()
1428+
old_doc = self.doc
1429+
1430+
# Switch to "New document" for now to make sure we lose
1431+
# all references to the document and pages in the UI/Canvas
1432+
self.__main_win.actions['new_doc'][1].do()
1433+
14281434
# this case is more tricky --> del + new
14291435
job = self.__main_win.job_factories['index_updater'].make(
14301436
self.__main_win.docsearch,
@@ -1439,20 +1445,23 @@ def apply_properties(self):
14391445
)
14401446
self.new_doc_date = None
14411447
self.__main_win.schedulers['main'].schedule(job)
1442-
1443-
self.__main_win.refresh_header_bar()
1448+
# XXX(JFlesch)
1449+
# at this point, be *really* careful to not trigger any operation
1450+
# that would recreate the document cache : we may be about
1451+
# to rename the document --> It means deleting it first
1452+
# --> no file descriptor must be opened on it
14441453

14451454
def __rename_doc(self, old_doc, new_doc_date):
1446-
old_doc.date = new_doc_date
14471455
old_doc.drop_cache()
1456+
old_doc.date = new_doc_date
14481457
job = self.__main_win.job_factories['index_updater'].make(
14491458
self.__main_win.docsearch,
14501459
new_docs={old_doc},
14511460
optimize=False,
14521461
reload_list=True
14531462
)
14541463
self.__main_win.schedulers['main'].schedule(job)
1455-
self.__main_win.show_doc(old_doc, force_refresh=True)
1464+
self.__main_win.show_doc(old_doc)
14561465

14571466
def _clear_label_list(self):
14581467
self.widgets['labels'].freeze_child_notify()

0 commit comments

Comments
 (0)