sw/source/uibase/docvw/FrameControlsManager.cxx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
New commits: commit 848fe845630c0092bc321a98e779923d0b97773a Author: Miklos Vajna <[email protected]> AuthorDate: Mon Feb 2 08:25:16 2026 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Mon Feb 2 11:30:04 2026 +0100 sw: fix crash in SwFrameControlsManager::SetContentControlAliasButton() gdb backtrace on the crashreport's core dump: #8 SwView::GetWrtShell (this=<optimized out>) at sw/inc/view.hxx:433 #9 SwFrameControlsManager::SetContentControlAliasButton (this=this@entry=0x53674d00, pContentControl=0x536d7210, aTopLeftPixel=...) at sw/source/uibase/docvw/FrameControlsManager.cxx:192 ... #19 0x000071084f165009 in SwWrtShell::GotoFieldmark (this=this@entry=0x552f4880, pMark=0x536d7e00) at sw/source/uibase/wrtsh/wrtsh3.cxx:227 #20 0x000071084f15d56b in SwWrtShell::SwWrtShell (this=this@entry=0x552f4880, rDoc=..., _pWin=<optimized out>, rShell=..., pViewOpt=pViewOpt@entry=0x7ffcab7ca2f0) at sw/source/uibase/wrtsh/wrtsh1.cxx:2118 #21 0x000071084e4a542c in SwView::SwView (this=this@entry=0x552f5180, _rFrame=..., pOldSh=pOldSh@entry=0x0) at include/rtl/ref.hxx:203 ... #29 0x000071085b272a05 in framework::LoadEnv::loadComponentFromURL (xLoader=..., xContext=..., sURL=..., sTarget=..., nSearchFlags=nSearchFlags@entry=0, lArgs=...) at framework/source/loadenv/loadenv.cxx:167 I.e. the document on load may have form protection on, in which case it jumps to the first fillable form, and if that happens to be inside a content control that has an alias/title defined, we hit this, probably. The problem is that the SwView ctor is not finished at this stage, so the view has no writer shell: (gdb) frame #9 SwFrameControlsManager::SetContentControlAliasButton (this=this@entry=0x53674d00, pContentControl=0x536d7210, aTopLeftPixel=...) at sw/source/uibase/docvw/FrameControlsManager.cxx:192 192 const SwViewOption* pViewOpt = m_pEditWin->GetView().GetWrtShell().GetViewOptions(); (gdb) print m_pEditWin.m_rInnerRef.m_pBody.m_rView.m_pWrtShell $5 = std::unique_ptr<SwWrtShell> = {get() = 0x0} Fix the problem by not assuming that the view has a writer shell set, which is usually true, except when the view creation is in progress. Change-Id: Ic7254e1ccbb9fdcafd94c04b829fae21a2322123 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198512 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Caolán McNamara <[email protected]> diff --git a/sw/source/uibase/docvw/FrameControlsManager.cxx b/sw/source/uibase/docvw/FrameControlsManager.cxx index 6fb7aac7458f..2e1455041da1 100644 --- a/sw/source/uibase/docvw/FrameControlsManager.cxx +++ b/sw/source/uibase/docvw/FrameControlsManager.cxx @@ -189,8 +189,12 @@ void SwFrameControlsManager::SetContentControlAliasButton(SwContentControl* pCon { pControl = std::make_shared<SwFrameControl>( VclPtr<SwContentControlAliasButton>::Create(m_pEditWin, pContentControl).get()); - const SwViewOption* pViewOpt = m_pEditWin->GetView().GetWrtShell().GetViewOptions(); - pControl->SetReadonly(pViewOpt->IsReadonly()); + SwWrtShell* pWrtShell = m_pEditWin->GetView().GetWrtShellPtr(); + if (pWrtShell) + { + const SwViewOption* pViewOpt = pWrtShell->GetViewOptions(); + pControl->SetReadonly(pViewOpt->IsReadonly()); + } rControls[nullptr] = pControl; }
