sfx2/source/dialog/StyleList.cxx | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-)
New commits: commit a7e1924a694e3a8616aa2db41ab08e0d80a51e5b Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Wed Apr 19 12:45:01 2023 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Wed Apr 19 13:58:24 2023 +0200 sfx2: fix crash in StyleList::CustomRenderHdl GetFamilyItem() might return nullptr See https://crashreport.libreoffice.org/stats/signature/StyleList::CustomRenderHdl(std::tuple%3COutputDevice%20&,tools::Rectangle%20const%20&,bool,rtl::OUString%20const%20&%3E) Change-Id: I099f045232aac710c4f26148de5e798d00ecc7ec Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150602 Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sfx2/source/dialog/StyleList.cxx b/sfx2/source/dialog/StyleList.cxx index be63cb5c6e31..dd8475052578 100644 --- a/sfx2/source/dialog/StyleList.cxx +++ b/sfx2/source/dialog/StyleList.cxx @@ -1556,21 +1556,24 @@ IMPL_LINK(StyleList, CustomRenderHdl, weld::TreeView::render_args, aPayload, voi if (pStyleManager) { - const SfxStyleFamilyItem* pItem = GetFamilyItem(); - SfxStyleSheetBase* pStyleSheet = pStyleManager->Search(rId, pItem->GetFamily()); - - if (pStyleSheet) + if (const SfxStyleFamilyItem* pItem = GetFamilyItem()) { - rRenderContext.Push(vcl::PushFlags::ALL); - // tdf#119919 - show "hidden" styles as disabled to not move children onto root node - if (pStyleSheet->IsHidden()) - rRenderContext.SetTextColor(rStyleSettings.GetDisableColor()); - - sal_Int32 nSize = aRect.GetHeight(); - std::unique_ptr<sfx2::StylePreviewRenderer> pStylePreviewRenderer( - pStyleManager->CreateStylePreviewRenderer(rRenderContext, pStyleSheet, nSize)); - bSuccess = pStylePreviewRenderer->recalculate() && pStylePreviewRenderer->render(aRect); - rRenderContext.Pop(); + SfxStyleSheetBase* pStyleSheet = pStyleManager->Search(rId, pItem->GetFamily()); + + if (pStyleSheet) + { + rRenderContext.Push(vcl::PushFlags::ALL); + // tdf#119919 - show "hidden" styles as disabled to not move children onto root node + if (pStyleSheet->IsHidden()) + rRenderContext.SetTextColor(rStyleSettings.GetDisableColor()); + + sal_Int32 nSize = aRect.GetHeight(); + std::unique_ptr<sfx2::StylePreviewRenderer> pStylePreviewRenderer( + pStyleManager->CreateStylePreviewRenderer(rRenderContext, pStyleSheet, nSize)); + bSuccess + = pStylePreviewRenderer->recalculate() && pStylePreviewRenderer->render(aRect); + rRenderContext.Pop(); + } } }