diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-04-19 12:45:01 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-04-19 13:58:24 +0200 |
commit | a7e1924a694e3a8616aa2db41ab08e0d80a51e5b (patch) | |
tree | 91f853ad6153c6c4b9d9a7b3ea7834edb957e289 /sfx2 | |
parent | 8550aff56cec3fbe3a4b8c753d6869d0ad94f702 (diff) |
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 <caolanm@redhat.com>
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/dialog/StyleList.cxx | 31 |
1 files changed, 17 insertions, 14 deletions
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(); + } } } |