desktop/source/app/app.cxx             |   21 ++++++---------------
 unotools/source/misc/VersionConfig.cxx |    6 ++++--
 2 files changed, 10 insertions(+), 17 deletions(-)

New commits:
commit f1e4a97b03e1eacd679c3ef1dcb7ab4b577dd928
Author:     Mike Kaganski <[email protected]>
AuthorDate: Sat Jun 15 11:36:29 2024 +0500
Commit:     Mike Kaganski <[email protected]>
CommitDate: Sat Jun 15 13:19:13 2024 +0200

    tdf#35568 Repeat "first run" procedure on upgrade
    
    1. In isProductVersionUpgraded, if it was upgraded, set FirstRun. This
       will run in runGraphicsRenderTests, early enough in Desktop::Main().
    2. This will make sure that Desktop::CheckFirstRun() will do its tasks,
       including creation  of the quickstart shortcut.  It is simplified a
       bit, to use a better WinAPI.
    3. Setting FirstRun to false is moved to m_firstRunTimer's handler, to
       make sure that it gets run eventually, even if the first launch was
       terminated before the timer fired.
    
    This will not make installer itself create the quickstart shortcut: it
    will happen on the program's first run after an upgrade. But users now
    won't have to enable the option manually each time.
    
    Change-Id: Ica6cc41f1e56b8970db27d14e2be3c47910293e3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168902
    Reviewed-by: Mike Kaganski <[email protected]>
    Tested-by: Jenkins

diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index b00dd75a39e6..d30bd0e582f3 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -2540,6 +2540,9 @@ IMPL_STATIC_LINK_NOARG(Desktop, AsyncInitFirstRun, Timer 
*, void)
     {
         Reference< XJobExecutor > xExecutor = theJobExecutor::get( 
::comphelper::getProcessComponentContext() );
         xExecutor->trigger( u"onFirstRunInitialization"_ustr );
+        auto batch(comphelper::ConfigurationChanges::create());
+        officecfg::Office::Common::Misc::FirstRun::set(false, batch);
+        batch->commit();
     }
     catch(const css::uno::Exception&)
     {
@@ -2608,24 +2611,12 @@ void Desktop::CheckFirstRun( )
 #ifdef _WIN32
     // Check if Quickstarter should be started (on Windows only)
     OUString sRootKey = 
ReplaceStringHookProc("Software\%OOOVENDOR\%PRODUCTNAME\%PRODUCTVERSION");
-    WCHAR szValue[8192];
-    DWORD nValueSize = sizeof(szValue);
-    HKEY hKey;
-    if (ERROR_SUCCESS == RegOpenKeyW(HKEY_LOCAL_MACHINE, 
o3tl::toW(sRootKey.getStr()), &hKey))
+    if (ERROR_SUCCESS == RegGetValueW(HKEY_LOCAL_MACHINE, 
o3tl::toW(sRootKey.getStr()), L"RunQuickstartAtFirstStart", RRF_RT_ANY, 
nullptr, nullptr, nullptr))
     {
-        if ( ERROR_SUCCESS == RegQueryValueExW( hKey, 
L"RunQuickstartAtFirstStart", nullptr, nullptr, 
reinterpret_cast<LPBYTE>(szValue), &nValueSize ) )
-        {
-            css::uno::Reference< css::uno::XComponentContext > xContext = 
::comphelper::getProcessComponentContext();
-            css::office::Quickstart::createAutoStart(xContext, 
true/*Quickstart*/, true/*bAutostart*/);
-            RegCloseKey( hKey );
-        }
+        css::uno::Reference< css::uno::XComponentContext > xContext = 
::comphelper::getProcessComponentContext();
+        css::office::Quickstart::createAutoStart(xContext, true/*Quickstart*/, 
true/*bAutostart*/);
     }
 #endif
-
-    std::shared_ptr< comphelper::ConfigurationChanges > batch(
-        comphelper::ConfigurationChanges::create());
-    officecfg::Office::Common::Misc::FirstRun::set(false, batch);
-    batch->commit();
 }
 
 }
diff --git a/unotools/source/misc/VersionConfig.cxx 
b/unotools/source/misc/VersionConfig.cxx
index f24451f6913d..80373ce73430 100644
--- a/unotools/source/misc/VersionConfig.cxx
+++ b/unotools/source/misc/VersionConfig.cxx
@@ -11,6 +11,7 @@
 
 #include <com/sun/star/lang/IllegalArgumentException.hpp>
 
+#include <officecfg/Office/Common.hxx>
 #include <officecfg/Setup.hxx>
 
 #include <o3tl/string_view.hxx>
@@ -35,9 +36,10 @@ bool isProductVersionUpgraded()
             //update lastversion
             try
             {
-                std::shared_ptr<comphelper::ConfigurationChanges> batch(
-                    comphelper::ConfigurationChanges::create());
+                auto batch(comphelper::ConfigurationChanges::create());
                 
officecfg::Setup::Product::ooSetupLastVersion::set(sSetupVersion, batch);
+                // tdf#35568: an upgrade must repeat the first run routine
+                officecfg::Office::Common::Misc::FirstRun::set(true, batch);
                 batch->commit();
             }
             catch (css::lang::IllegalArgumentException&)

Reply via email to