diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-08-18 15:51:35 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-08-19 09:53:40 +0200 |
commit | 898b8e653824da62bbd2d34430c85901da7c5222 (patch) | |
tree | 7e33ab4561c062e39d0f683e7bff6c7e78b8e5fd | |
parent | 0e16b40d8b68f73731b4aa9059d0f98d0489fed0 (diff) |
save LastTipOfTheDayShown when the dialog is shown not in its dtor
Otherwise if a tip dialog is left open then its considered not to be
have be shown and new ones will constantly open on every new
document. Especially problematic in impress if you leave the first
one open and select a template to open from the template dialog then
you get two of them in the same frame.
Change-Id: I94cd34aa031e133d8c229a0de78582fda1dbdf4a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120674
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | cui/source/dialogs/tipofthedaydlg.cxx | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/cui/source/dialogs/tipofthedaydlg.cxx b/cui/source/dialogs/tipofthedaydlg.cxx index 8356f6f0e36f..c4d1f876f935 100644 --- a/cui/source/dialogs/tipofthedaydlg.cxx +++ b/cui/source/dialogs/tipofthedaydlg.cxx @@ -74,6 +74,15 @@ TipOfTheDayDialog::TipOfTheDayDialog(weld::Window* pParent) const auto t0 = std::chrono::system_clock::now().time_since_epoch(); m_nDay = std::chrono::duration_cast<std::chrono::hours>(t0).count() / 24; + + // save this time to the config now instead of in the dtor otherwise we + // end up with multiple copies of this dialog every time we open a new + // document if the first one isn't closed + std::shared_ptr<comphelper::ConfigurationChanges> xChanges( + comphelper::ConfigurationChanges::create()); + officecfg::Office::Common::Misc::LastTipOfTheDayShown::set(m_nDay, xChanges); + xChanges->commit(); + if (m_nDay > officecfg::Office::Common::Misc::LastTipOfTheDayShown::get()) m_nCurrentTip++; @@ -90,7 +99,6 @@ TipOfTheDayDialog::~TipOfTheDayDialog() { std::shared_ptr<comphelper::ConfigurationChanges> xChanges( comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Misc::LastTipOfTheDayShown::set(m_nDay, xChanges); officecfg::Office::Common::Misc::LastTipOfTheDayID::set(m_nCurrentTip, xChanges); officecfg::Office::Common::Misc::ShowTipOfTheDay::set(m_pShowTip->get_active(), xChanges); xChanges->commit(); |