desktop/source/app/app.cxx         |    7 +++++++
 desktop/source/app/cmdlineargs.cxx |    5 +++++
 desktop/source/app/cmdlineargs.hxx |    1 +
 3 files changed, 13 insertions(+)

New commits:
commit 4963fc47a0381967246e15479bf79bb58dddc465
Author:     Justin Luth <jl...@mail.com>
AuthorDate: Tue Jan 2 14:20:29 2024 -0500
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Wed Jan 3 05:51:57 2024 +0100

    tdf117100: do not attempt to re-install extensions on restart
    
    A common way to install extensions is to simply double-click
    on them in the OS's file browser. But in this case the reload
    still contains the extension in the cmdline and thus it
    "opens" the extension again and asks to re-install.
    So just eliminate OXTs from the commandline if OfficeRestartInProgress.
    
    If multiple OXTs are provided on the commandline, two things happen:
    -LO crashes (with an assert)
    -both extensions are successfully installed before restart is requested.
    
    In both cases removing ALL extensions during restart is appropriate.
    
    Prior to this patch, OfficeRestartInProgress was not actually used AFAICS.
    
    Mike Kaganski laid out lots of good criteria for this patch
    1. After restart, user can still manually install an extension: YES
    2. A restart after a restart should still inhibit extensions: YES
    3. Must no interfere is user choses to "restart later": YES
    4. It works with a clean profile (rm -r instdir/user): YES
    
    This implementation is closest to his suggested
    > Variant 4. Cleanup all fileopen/print arguments from the guards
    > that manage restarts (e.g., soffice.exe on Windows), so that
    > when restarting, they would not repeat using those arguments again.
    > Problem: first launch of soffice.bin that initializes user profile:
    > restart after this should repeat all the command line arguments.
    
    Change-Id: I2460cb31be0c6f3e10cbb5b200cf67839cbd822a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161549
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 0d66a48daac7..370fc5761553 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -478,6 +478,13 @@ void Desktop::Init()
     // the UserConfiguration directory
     
comphelper::BackupFileHelper::reactOnSafeMode(Application::IsSafeModeEnabled());
 
+    // tdf117100: do not try to re-install extensions after the requested 
restart
+    if (officecfg::Setup::Office::OfficeRestartInProgress::get())
+    {
+        if (!officecfg::Office::Common::Misc::FirstRun::get())
+            GetCommandLineArgs().RemoveFilesFromOpenListEndingWith(".oxt");
+    }
+
     try
     {
         if (!langselect::prepareLocale())
diff --git a/desktop/source/app/cmdlineargs.cxx 
b/desktop/source/app/cmdlineargs.cxx
index e7f315204048..f96814e8e7ff 100644
--- a/desktop/source/app/cmdlineargs.cxx
+++ b/desktop/source/app/cmdlineargs.cxx
@@ -736,6 +736,11 @@ bool CommandLineArgs::HasModuleParam() const
         || m_web || m_base;
 }
 
+void CommandLineArgs::RemoveFilesFromOpenListEndingWith(const OUString& rExt)
+{
+    std::erase_if(m_openlist, [rExt](OUString url) { return 
url.endsWithIgnoreAsciiCase(rExt); });
+}
+
 std::vector< OUString > CommandLineArgs::GetOpenList() const
 {
     return translateExternalUris(m_openlist);
diff --git a/desktop/source/app/cmdlineargs.hxx 
b/desktop/source/app/cmdlineargs.hxx
index 64a1bcfd0ccb..a9eca1d980f1 100644
--- a/desktop/source/app/cmdlineargs.hxx
+++ b/desktop/source/app/cmdlineargs.hxx
@@ -99,6 +99,7 @@ class CommandLineArgs
         bool                    HasSplashPipe() const { return m_splashpipe;}
         std::vector< OUString > const & GetAccept() const { return m_accept;}
         std::vector< OUString > const & GetUnaccept() const { return 
m_unaccept;}
+        void RemoveFilesFromOpenListEndingWith(const OUString& rExt);
         std::vector< OUString > GetOpenList() const;
         std::vector< OUString > GetViewList() const;
         std::vector< OUString > GetStartList() const;

Reply via email to