vcl/source/window/dialog.cxx |   28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

New commits:
commit b31e78fd035b520fd4ff2238c8997d5db166ef9e
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Thu Dec 26 17:18:47 2024 +0500
Commit:     Adolfo Jayme Barrientos <fit...@ubuntu.com>
CommitDate: Wed Jan 1 09:12:22 2025 +0100

    LOK: don't crash when trying to show a dialog during file load
    
    Opening an ODP with a linked object, which wants to show a "update
    links?" dialog during the load, would assert in Online debug build
    with this stack:
    
      libvcllo.so!vcl::Window::SetLOKNotifier(vcl::Window * const this, const 
vcl::ILibreOfficeKitNotifier * pNotifier, bool bParent) Line 3188
      libvcllo.so!Dialog::ImplStartExecute(Dialog * const this) Line 940
      libvcllo.so!Dialog::Execute(Dialog * const this) Line 1072
      libvcllo.so!SalInstanceDialog::run(SalInstanceDialog * const this) Line 
1881
      libvcllo.so!JSMessageDialog::run(JSMessageDialog * const this) Line 1483
      libsfxlo.so!sfx2::LinkManager::UpdateAllLinks(sfx2::LinkManager * const 
this, bool bAskUpdate, bool bUpdateGrfLinks, weld::Window * pParentWin) Line 333
      libsdlo.so!SdDrawDocument::UpdateAllLinks(SdDrawDocument * const this) 
Line 827
      libsdlo.so!SdXMLFilter::Import(SdXMLFilter * const this, ErrCode & 
nError) Line 647
      libsdlo.so!sd::DrawDocShell::Load(sd::DrawDocShell * const this, 
SfxMedium & rMedium) Line 299
      libsfxlo.so!SfxObjectShell::LoadOwnFormat(SfxObjectShell * const this, 
SfxMedium & rMedium) Line 3320
      libsfxlo.so!SfxObjectShell::DoLoad(SfxObjectShell * const this, SfxMedium 
* pMed) Line 705
      libsfxlo.so!SfxBaseModel::load(SfxBaseModel * const this, const 
com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> & 
seqArguments) Line 1983
      libsfxlo.so!(anonymous namespace)::SfxFrameLoader_Impl::load((anonymous 
namespace)::SfxFrameLoader_Impl * const this, const 
com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> & rArgs, 
const com::sun::star::uno::Reference<com::sun::star::frame::XFrame> & 
_rTargetFrame) Line 725
      libfwklo.so!framework::LoadEnv::impl_loadContent(framework::LoadEnv * 
const this) Line 1176
      libfwklo.so!framework::LoadEnv::start(framework::LoadEnv * const this) 
Line 412
      libfwklo.so!framework::LoadEnv::startLoading(framework::LoadEnv * const 
this, const rtl::OUString & sURL, const 
com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> & 
lMediaDescriptor, const 
com::sun::star::uno::Reference<com::sun::star::frame::XFrame> & xBaseFrame, 
const rtl::OUString & sTarget, sal_Int32 nSearchFlags, LoadEnvFeatures 
eFeature) Line 308
      libfwklo.so!framework::LoadEnv::loadComponentFromURL(const 
com::sun::star::uno::Reference<com::sun::star::frame::XComponentLoader> & 
xLoader, const 
com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> & 
xContext, const rtl::OUString & sURL, const rtl::OUString & sTarget, sal_Int32 
nSearchFlags, const 
com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> & lArgs) 
Line 168
      libfwklo.so!framework::Desktop::loadComponentFromURL(framework::Desktop * 
const this, const rtl::OUString & sURL, const rtl::OUString & sTargetFrameName, 
sal_Int32 nSearchFlags, const 
com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> & 
lArguments) Line 592
      libsofficeapp.so!lo_documentLoadWithOptions(LibreOfficeKit * pThis, const 
char * pURL, const char * pOptions) Line 2927
      lok::Office::documentLoad(lok::Office * const this, const char * 
pFilterOptions, const char * pUrl) Line 981
      Document::load(Document * const this, const std::shared_ptr<ChildSession> 
& session, const std::string & renderOpts) Line 1927
      Document::onLoad(Document * const this, const std::string & sessionId, 
const std::string & uriAnonym, const std::string & renderOpts) Line 1224
      ChildSession::loadDocument(ChildSession * const this,  tokens) Line 932
      ChildSession::_handleInput(ChildSession * const this, const char * 
buffer, int length) Line 310
      Session::handleMessage(Session * const this, const std::vector<char, 
std::allocator<char> > & data) Line 311
      Document::forwardToChild(Document * const this,  prefix,  payload) Line 
2139
      Document::drainQueue(Document * const this) Line 238
      KitSocketPoll::drainQueue(KitSocketPoll * const this) Line 2794
      KitSocketPoll::kitPoll(KitSocketPoll * const this, int timeoutMicroS) 
Line 2873
      libvcllo.so!SvpSalInstance::ImplYield(SvpSalInstance * const this, bool 
bWait, bool bHandleAllCurrentEvents) Line 434
      libvcllo.so!SvpSalInstance::DoYield(SvpSalInstance * const this, bool 
bWait, bool bHandleAllCurrentEvents) Line 475
      libvcllo.so!ImplYield(bool i_bWait, bool i_bAllEvents) Line 396
      libvcllo.so!Application::Yield() Line 480
      libvcllo.so!Application::Execute() Line 374
      libsofficeapp.so!desktop::Desktop::Main(desktop::Desktop * const this) 
Line 1605
      libvcllo.so!ImplSVMain() Line 229
      libvcllo.so!SVMain() Line 261
      libsofficeapp.so!soffice_main() Line 94
      libsofficeapp.so!lo_runLoop(LibreOfficeKitPollCallback pPollCallback, 
LibreOfficeKitWakeCallback pWakeCallback, void * pData) Line 7846
      lok::Office::runLoop(void * pData, LibreOfficeKitWakeCallback 
pWakeCallback, LibreOfficeKitPollCallback pPollCallback) Line 1135
      lokit_main(const std::string & childRoot, const std::string & jailId, 
const std::string & sysTemplate, const std::string & loTemplate, bool 
noCapabilities, bool noSeccomp, bool useMountNamespaces, bool queryVersion, 
bool displayVersion, bool sysTemplateIncomplete, std::size_t numericIdentifier) 
Line 3691
      createLibreOfficeKit(const std::string & childRoot, const std::string & 
sysTemplate,  loTemplate, bool useMountNamespaces, bool queryVersion) Line 490
      forkit_main(int argc, char ** argv) Line 872
    
    Change-Id: I45c20ed8c46e927301aa1de43179638a17608a26
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179430
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    (cherry picked from commit f8528cdda9292c7ae6c9d49b80c1a3a3b4a67094)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179436
    Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>

diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index ed51851aaa49..430ef9136d4e 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -925,18 +925,22 @@ bool Dialog::ImplStartExecute()
     {
         if (bKitActive && !GetLOKNotifier())
         {
-#ifdef IOS
-            // gh#5908 handle pasting disallowed clipboard contents on iOS
-            // When another app owns the current clipboard contents, pasting
-            // will display a "allow or disallow" dialog. If the disallow
-            // option is selected, the data from the UIPasteboard will be
-            // garbage and we will find ourselves here. Since calling
-            // SetLOKNotifier() with a nullptr aborts in an assert(), fix
-            // the crash by failing gracefully.
-            return false;
-#else
-            
SetLOKNotifier(mpDialogImpl->m_aInstallLOKNotifierHdl.Call(nullptr));
-#endif
+            if (auto pNotifier = 
mpDialogImpl->m_aInstallLOKNotifierHdl.Call(nullptr))
+                SetLOKNotifier(pNotifier);
+            else
+            {
+                // gh#5908 handle pasting disallowed clipboard contents on iOS
+                // When another app owns the current clipboard contents, 
pasting
+                // will display a "allow or disallow" dialog. If the disallow
+                // option is selected, the data from the UIPasteboard will be
+                // garbage and we will find ourselves here. Since calling
+                // SetLOKNotifier() with a nullptr aborts in an assert(), fix
+                // the crash by failing gracefully.
+
+                // Also pNotifier may be nullptr when a dialog (e.g., "update
+                // links?") is to be shown when loading a document.
+                return false;
+            }
         }
 
         switch ( Application::GetDialogCancelMode() )

Reply via email to