Store bookmark as soon as it's created

Bug #1733176 reported by Daniel Bedrenko
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
qpdfview
Fix Released
Wishlist
Adam Reichold

Bug Description

It would be great if when a bookmark is created, this is immediately saved to storage. It's very annoying that if my OS crashes for whatever reason, like power is accidentally cut, that all my annotations and comments are lost! This has happened countless times.

Thank you for the great software, it is my main PDF reader.

Tags: bookmark
Revision history for this message
Daniel Bedrenko (dbedrenko) wrote :

This is currently the case for v0.4.16 on Linux.

Revision history for this message
Adam Reichold (adamreichold) wrote :

Hello Daniel,

thank you for taking the time to report this. The interval in which changes to qpdfview's internal database containing open tabs, bookmarks and per-file settings is saved to persistent storage is configurable via the "Save interval" settings on the "Behavior tab" of the settings dialog and has a default value of five minutes.

I just pushed a change to qpdfview's trunk that makes it possible to set a value of zero, meaning that scheduled changes will be saved to disk immediately after UI events have been processed. Setting it to something smaller than zero will now have the meaning of "Never".

Note that this does not apply to PDF-based annotations made directly inside the document which are saved only manually when the document is saved.

Best regards, Adam.

Changed in qpdfview:
status: New → Fix Committed
importance: Undecided → Wishlist
assignee: nobody → Adam Reichold (adamreichold)
milestone: none → 0.4.18
Revision history for this message
Daniel Bedrenko (dbedrenko) wrote :

Thank you very much, I was not aware of this feature.

Revision history for this message
crtxcr (crtxcr) wrote :

>I just pushed a change to qpdfview's trunk that makes it possible to set a value of zero, >meaning that scheduled changes will be saved to disk immediately after UI events have been >processed. Setting it to something smaller than zero will now have the meaning of "Never".

I don't think this is the best solution, because as a side effect the database will be rewritten every time (unless I am misunderstanding something). But the way I understand it is that any scheduled change currently will essentially trigger QMainWindow::saveDatabase(). This then triggers Database::saveTabs, Database::saveBookmarks(), and Database::savePerFileSettings. These functions then usually first clear the tables before inserting everything again. A better way is to only write back the changes that actually happened instead of everything, because with this change simply changing the page in a document will rewrite most of the database just to store the current page we are in.

So I suggest the following as a start:
-Save/Modify/Delete bookmarks immediately. Don't schedule this change and don't rewrite the table. May require a method like Database::saveBookmarkItem() and so on;
-MainWindow::scheduleSavePerFileSettings() should schedule only Database::savePerFileSettings, not QMainWindow::saveDatabase. Same is probably true for scheduleSaveTabs.

Revision history for this message
Adam Reichold (adamreichold) wrote :

Hello,

I do not think rewriting the tables is really an issue since the whole database is usually a few tens of pages large and it avoids fragmentation issues. It also more importantly avoids having to keep track identity of the database rows within the application in any way.

Best regards, Adam.

Changed in qpdfview:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.