Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving history and favorites on unusual situations (e.g. cutting off of power cord) #1375

Closed
BEST8OY opened this issue Jan 24, 2024 · 7 comments · Fixed by #1814
Closed

Saving history and favorites on unusual situations (e.g. cutting off of power cord) #1375

BEST8OY opened this issue Jan 24, 2024 · 7 comments · Fixed by #1814

Comments

@BEST8OY
Copy link
Contributor

BEST8OY commented Jan 24, 2024

Describe the bug
GD can't save the latest state of History and Favorites on Arch Linux if GD is in background and you initiate a restart or shutdown.

To Reproduce
Steps to reproduce the behavior:

  1. Search some words and star some words
  2. Close GD to background
  3. Restart
  4. Open GD and your searches and favorites are not there (Of course the saving interval is on 0)

Expected behavior
It should save them.

OS and software versions

Goldendict-ng 24.01.22 at 2024-01-23T17:36:50
Qt 6.6.1 GCC 13.2.1 20230801 arch linux 6.7.0-arch3-1 x86_64-little_endian-lp64
Flags:USE_XAPIAN MAKE_ZIM_SUPPORT USE_ICONV MAKE_CHINESE_CONVERSION_SUPPORT

@xiaoyifang
Copy link
Owner

xiaoyifang commented Jan 24, 2024

I guess the reason is that when restart the os ,the gd got no chance to save the config file.

@BEST8OY
Copy link
Contributor Author

BEST8OY commented Jan 24, 2024

I guess the reason is that when restart the os ,the gd got no chance to save the config file.

Is there any way to overcome this?
Windows closes all the apps before initiating shutdown or restart thus no problem I suppose!?
Is it not the same on Linux?

@xiaoyifang
Copy link
Owner

Can you test this PR #1389

@BEST8OY
Copy link
Contributor Author

BEST8OY commented Jan 29, 2024

Can you test this PR #1389

I built from that branch with cmake
executed it
did some stuff and rebooted
but the last state was not saved

@xiaoyifang
Copy link
Owner

Thanks for you effort . gd-ng need a chance to save the config .

Has no clue right now.

@fanguohao
Copy link

Thanks for you effort . gd-ng need a chance to save the config .

Has no clue right now.

I found the latest favorite words can only be archived to local config file <favorites.txt> when the app is properly exited. Is it possilbe to synchronize the local config file with the cache/swap file loaded by the flatpak when a new favorite word is added?

Environment: Ubuntu 22.04

@shenlebantongying
Copy link
Collaborator

Saving history/favorite at interval already exists

history.setSaveInterval( cfg.preferences.historyStoreInterval );

We should set an initial value of maybe 15 mins.


I check how Qt6's timer is implemented.

QTimer wraps QBasicTimer which wraps std::chrono::steady_clock which wraps clock_gettime.

The QBasicTimer is a global timer, and all other timers merely register timers. For the default Qt::CoarseTimer, registering arbitrary number of timers has almost no impact on CPU usages 😅.

@shenlebantongying shenlebantongying changed the title Saving history and favorites issue on Arch linux Saving history and favorites on catastrophic situations (e.g. direct cutting off of power cord) Oct 10, 2024
@shenlebantongying shenlebantongying changed the title Saving history and favorites on catastrophic situations (e.g. direct cutting off of power cord) Saving history and favorites on unusual situations (e.g. direct cutting off of power cord) Oct 10, 2024
@shenlebantongying shenlebantongying changed the title Saving history and favorites on unusual situations (e.g. direct cutting off of power cord) Saving history and favorites on unusual situations (e.g. cutting off of power cord) Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants