Skip to content

Fix issue: save MainWindow geometry, windowState, etc. on exit - #2536

Merged
mgrojo merged 1 commit into
sqlitebrowser:masterfrom
cpina:save-settings-before-exiting
Jan 15, 2021
Merged

mgrojo merged 1 commit into
sqlitebrowser:masterfrom
cpina:save-settings-before-exiting

Conversation

@cpina

@cpina cpina commented Jan 11, 2021

Copy link
Copy Markdown
Contributor

In MainWindow::closeEvent() now it calls Settings::sync() to call
QSettings->sync(). Qt documentation
(https://doc.qt.io/qt-5/qsettings.html#sync) says:

"This function is called automatically from QSettings's destructor and
by the event loop at regular intervals, so you normally don't need to
call it yourself."

On my Linux machine QSettings was not syncing to the
~/.config/sqlitebrowser/sqlitebrowser.conf (e.g. if I was doing View ->
Window Layout -> Simplify Window Layout and then close quickly was not
saved). Other settings recently changed before exiting would have been
the same.

Note that Settings is fully static so this seems to be an easy fix.

In MainWindow::closeEvent() now it calls Settings::sync() to call
QSettings->sync(). Qt documentation
(https://doc.qt.io/qt-5/qsettings.html#sync) says:

"This function is called automatically from QSettings's destructor and
by the event loop at regular intervals, so you normally don't need to
call it yourself."

On my Linux machine QSettings was not syncing to the
~/.config/sqlitebrowser/sqlitebrowser.conf (e.g. if I was doing View ->
Window Layout -> Simplify Window Layout and then close quickly was not
saved). Other settings recently changed before exiting would have been
the same.

Note that Settings is fully static so this seems to be an easy fix.
@justinclift

Copy link
Copy Markdown
Member

Without reviewing the code, the concept itself seems like a good idea. 😄

@mgrojo
mgrojo merged commit 88ca9fa into sqlitebrowser:master Jan 15, 2021
@mgrojo

mgrojo commented Jan 15, 2021

Copy link
Copy Markdown
Member

Thanks, Carles! I've merged it to master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants