sfx2/source/appl/linkmgr2.cxx | 25 +++++++++++++++++-------- vcl/source/window/dialog.cxx | 4 ++++ 2 files changed, 21 insertions(+), 8 deletions(-)
New commits: commit ff41053e7700e5489630869afb4e063f5c8a2ede Author: Mike Kaganski <[email protected]> AuthorDate: Thu Jan 16 13:21:46 2025 +0500 Commit: Mike Kaganski <[email protected]> CommitDate: Fri Jan 17 11:48:49 2025 +0100 LOK: Do not try to show an "update links" dialog In commit f8528cdda9292c7ae6c9d49b80c1a3a3b4a67094 (LOK: don't crash when trying to show a dialog during file load, 2024-12-26), all not yet async / not properly set up dialogs made to fail gracefully. In the follow-up https://gerrit.libreoffice.org/c/core/+/180334, an assert is added to still fail in debug builds. The specific "update links" dialog case, that triggered the original change in the first place, does not need to appear at all in the LOK case, because there is no external documents available for updating. This change avoids the dialog in that case. Change-Id: I7c6bc755d87656f002829460f4768fed34dc2f17 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180335 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/sfx2/source/appl/linkmgr2.cxx b/sfx2/source/appl/linkmgr2.cxx index 8a54ac946945..6d9bb0476e17 100644 --- a/sfx2/source/appl/linkmgr2.cxx +++ b/sfx2/source/appl/linkmgr2.cxx @@ -17,6 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <comphelper/lok.hxx> #include <comphelper/string.hxx> #include <sfx2/linkmgr.hxx> #include <sfx2/sfxsids.hrc> @@ -278,6 +281,12 @@ bool LinkManager::GetDisplayNames( const SvBaseLink * pLink, return bRet; } +static void disallowAllLinksUpdate(SvBaseLink* pShellProvider) +{ + if (SfxObjectShell* pShell = pShellProvider->GetLinkManager()->GetPersist()) + pShell->getEmbeddedObjectContainer().setUserAllowsLinkUpdate(false); +} + void LinkManager::UpdateAllLinks( bool bAskUpdate, bool bUpdateGrfLinks, @@ -325,6 +334,13 @@ void LinkManager::UpdateAllLinks( if( bAskUpdate ) { + if (comphelper::LibreOfficeKit::isActive()) + { + // only one document in jail, no update possible + disallowAllLinksUpdate(pLink); + return; + } + OUString aMsg = SfxResId(STR_QUERY_UPDATE_LINKS); INetURLObject aURL(pPersist->getDocumentBaseURL()); aMsg = aMsg.replaceFirst("%{filename}", aURL.GetLastName()); @@ -336,14 +352,7 @@ void LinkManager::UpdateAllLinks( int nRet = xQueryBox->run(); if( RET_YES != nRet ) { - SfxObjectShell* pShell = pLink->GetLinkManager()->GetPersist(); - - if(pShell) - { - comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = pShell->getEmbeddedObjectContainer(); - rEmbeddedObjectContainer.setUserAllowsLinkUpdate(false); - } - + disallowAllLinksUpdate(pLink); return ; // nothing should be updated } bAskUpdate = false; // once is enough commit f7499659050ace3d4a6aa133853125138f969ac4 Author: Mike Kaganski <[email protected]> AuthorDate: Thu Jan 16 13:04:25 2025 +0500 Commit: Mike Kaganski <[email protected]> CommitDate: Fri Jan 17 11:48:42 2025 +0100 Add an assert to allow debugging not yet async dialogs Commit f8528cdda9292c7ae6c9d49b80c1a3a3b4a67094 (LOK: don't crash when trying to show a dialog during file load, 2024-12-26) fixed a crash when a not async / not properly set up dialog was attempted in Online. This is reasonable in release builds, but the added assert helps to find the problem in development (debug) builds. Change-Id: Ie75574cc7a69de06f6b63925249a5da2e50abb6f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180334 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index 8b33aa64c8db..ecf2302bfe4d 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -939,6 +939,10 @@ bool Dialog::ImplStartExecute() // Also pNotifier may be nullptr when a dialog (e.g., "update // links?") is to be shown when loading a document. + // Never crash in release builds (assume "cancel"), but allow + // to see the not yet async / not properly set up dialogs in + // debug builds. + assert(!"A dialog without a notifier: make me async / properly set up"); return false; } }
