sfx2/source/view/viewsh.cxx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
New commits: commit b9d6213d04c84b8d514be597d8c876caf9c48be9 Author: Miklos Vajna <[email protected]> AuthorDate: Wed Dec 10 10:18:41 2025 +0100 Commit: Miklos Vajna <[email protected]> CommitDate: Fri Dec 12 01:26:28 2025 +0100 sfx2: fix uncaught exception in SfxViewShell::Activate() gdb backtrace on the core file from crashreport: #0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=123946821978048) at ./nptl/pthread_kill.c:44 #1 __pthread_kill_internal (signo=6, threadid=123946821978048) at ./nptl/pthread_kill.c:78 #2 __GI___pthread_kill (threadid=123946821978048, signo=signo@entry=6) at ./nptl/pthread_kill.c:89 #3 0x000070ba9de42476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26 #4 0x000070ba9de287f3 in __GI_abort () at ./stdlib/abort.c:79 #5 0x000070ba9e2a2b9e in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6 #6 0x000070ba9e2ae20c in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6 #7 0x000070ba9e2ae277 in std::terminate() () from /lib/x86_64-linux-gnu/libstdc++.so.6 #8 0x000070ba9e2ae4d8 in __cxa_throw () from /lib/x86_64-linux-gnu/libstdc++.so.6 #9 0x000070ba9818129b in SfxBaseModel::MethodEntryCheck (this=<optimized out>, i_mustBeInitialized=<optimized out>) at sfx2/source/doc/sfxbasemodel.cxx:3069 #10 0x000070ba99e6c8cb in SfxModelGuard::SfxModelGuard (i_eState=SfxModelGuard::E_FULLY_ALIVE, i_rModel=..., this=0x7ffedd2f94f0) at sfx2/source/inc/docundomanager.hxx:76 #11 SfxBaseModel::setCurrentController (this=0x194e84b0, xCurrentController=...) at sfx2/source/doc/sfxbasemodel.cxx:1364 #12 0x000070ba99f6955a in SfxViewShell::Activate (this=0x2b084ed0, bMDI=<optimized out>) at sfx2/source/view/viewsh.cxx:2535 And that std::terminate() prints: terminate called after throwing an instance of 'com::sun::star::lang::NotInitializedException' Fix the problem similar to what commit adadeaf98114ffdf9893e6c92a630f7e90597f62 (avoid terminate after unhandled exception, 2025-11-26) did, but here note that SfxViewShell::Activate() ignores the case when the object shell has no base model. So extend that and in case the object shell has a base model, but it's not initialized, do the same (ignore the problem that setCurrentController() could not finish successfully). This solves the high level problem that processing an user event on the main loop should not throw exceptions. Change-Id: Ibd6309d7de12964a35a914c16fabc5fc7f61b39b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195477 Tested-by: Jenkins Reviewed-by: Miklos Vajna <[email protected]> diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index aa9dc9b58275..da3ea1091fdc 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -2534,7 +2534,16 @@ void SfxViewShell::Activate( bool bMDI ) { SfxObjectShell *pSh = GetViewFrame().GetObjectShell(); if (const auto xModel = pSh->GetModel()) - xModel->setCurrentController(GetController()); + { + try + { + xModel->setCurrentController(GetController()); + } + catch (const uno::Exception&) + { + TOOLS_WARN_EXCEPTION("sfx.view", "SfxViewShell::Activate: failed to set current controller"); + } + } SetCurrentDocument(); }
