summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2022-11-03 09:14:18 +0100
committerMichael Stahl <michael.stahl@allotropia.de>2023-11-24 21:58:21 +0100
commit7191131075e257eb41684df44d9d4fc40d0d1207 (patch)
tree8b539783086164dca5da72a812ffe3d8aa79cdc6
parent314bc7b9ac0a52e19a28fe7ebf10751ef84db86f (diff)
-Werror=dangling-reference
In <https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=d2249cd9adf5ae638577139177a50f7e62d8abd9> "c++: Implement -Wdangling-reference [PR106393]" grew a new warning, included in -Wall, and based on some more-or-less shaky heuristics, that warns about "possibly dangling reference to a temporary". It produces quite a number of false positives, but for these uses of SfxItemSet::Get it does look plausible that the returned item references could, at least in theory, point at data that is destroyed along with the temporary SfxItemSet. Change-Id: I11afc4512db488f73170c6cfa706e9e094209550 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142217 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com> (cherry picked from commit e0121b2478526d803681d57d59af0cbf9cf602b4) (cherry picked from commit 6231cbaf9dfc558cf7238b976970c86955e27f35)
-rw-r--r--editeng/source/accessibility/AccessibleEditableTextPara.cxx3
-rw-r--r--sc/source/ui/drawfunc/drtxtob.cxx3
-rw-r--r--sc/source/ui/view/editsh.cxx3
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx8
4 files changed, 9 insertions, 8 deletions
diff --git a/editeng/source/accessibility/AccessibleEditableTextPara.cxx b/editeng/source/accessibility/AccessibleEditableTextPara.cxx
index c68c79ebea8f..c87071b97324 100644
--- a/editeng/source/accessibility/AccessibleEditableTextPara.cxx
+++ b/editeng/source/accessibility/AccessibleEditableTextPara.cxx
@@ -1527,8 +1527,7 @@ namespace accessibility
// NumberingLevel
if (rRes.Name == "NumberingLevel")
{
- const SvxNumBulletItem& rNumBullet = rCacheTF.GetParaAttribs(GetParagraphIndex()).Get(EE_PARA_NUMBULLET);
- if(rNumBullet.GetNumRule()->GetLevelCount()==0)
+ if(rCacheTF.GetParaAttribs(GetParagraphIndex()).Get(EE_PARA_NUMBULLET).GetNumRule()->GetLevelCount()==0)
{
rRes.Value <<= sal_Int16(-1);
rRes.Handle = -1;
diff --git a/sc/source/ui/drawfunc/drtxtob.cxx b/sc/source/ui/drawfunc/drtxtob.cxx
index 2cdf432edc11..dd06436be6b9 100644
--- a/sc/source/ui/drawfunc/drtxtob.cxx
+++ b/sc/source/ui/drawfunc/drtxtob.cxx
@@ -205,7 +205,8 @@ void ScDrawTextObjectBar::Execute( SfxRequest &rReq )
case SID_CHARMAP:
{
- const SvxFontItem& rItem = pOutView->GetAttribs().Get(EE_CHAR_FONTINFO);
+ auto const attribs = pOutView->GetAttribs();
+ const SvxFontItem& rItem = attribs.Get(EE_CHAR_FONTINFO);
OUString aString;
std::shared_ptr<SvxFontItem> aNewItem(std::make_shared<SvxFontItem>(EE_CHAR_FONTINFO));
diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx
index 61888c663ef4..413041e0d0e0 100644
--- a/sc/source/ui/view/editsh.cxx
+++ b/sc/source/ui/view/editsh.cxx
@@ -385,8 +385,9 @@ void ScEditShell::Execute( SfxRequest& rReq )
sal_uInt16 nFontWhich = ( nScript == SvtScriptType::ASIAN ) ? EE_CHAR_FONTINFO_CJK :
( ( nScript == SvtScriptType::COMPLEX ) ? EE_CHAR_FONTINFO_CTL :
EE_CHAR_FONTINFO );
+ auto const attribs = pTableView->GetAttribs();
const SvxFontItem& rItem = static_cast<const SvxFontItem&>(
- pTableView->GetAttribs().Get(nFontWhich));
+ attribs.Get(nFontWhich));
OUString aString;
std::shared_ptr<SvxFontItem> aNewItem(std::make_shared<SvxFontItem>(EE_CHAR_FONTINFO));
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index ff379531338f..a576c2a236bc 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -1337,8 +1337,8 @@ void SdTiledRenderingTest::testTdf102223()
EditView& rEditView = pView->GetTextEditOutlinerView()->GetEditView();
rEditView.SetSelection(ESelection(0, 0, 0, 3)); // start para, start char, end para, end char.
CPPUNIT_ASSERT_EQUAL(OUString("Red"), rEditView.GetSelected());
- const SvxFontHeightItem& rItem = rEditView.GetAttribs().Get(EE_CHAR_FONTHEIGHT);
- CPPUNIT_ASSERT_EQUAL(int(1411), static_cast<int>(rItem.GetHeight()));
+ CPPUNIT_ASSERT_EQUAL(
+ int(1411), static_cast<int>(rEditView.GetAttribs().Get(EE_CHAR_FONTHEIGHT).GetHeight()));
// cut contents of cell
uno::Sequence<beans::PropertyValue> aArgs;
@@ -1349,8 +1349,8 @@ void SdTiledRenderingTest::testTdf102223()
CPPUNIT_ASSERT(pView->GetTextEditObject());
EditView& rEditView2 = pView->GetTextEditOutlinerView()->GetEditView();
rEditView2.SetSelection(ESelection(0, 0, 0, 1)); // start para, start char, end para, end char.
- const SvxFontHeightItem& rItem2 = rEditView2.GetAttribs().Get(EE_CHAR_FONTHEIGHT);
- CPPUNIT_ASSERT_EQUAL(int(1411), static_cast<int>(rItem2.GetHeight()));
+ CPPUNIT_ASSERT_EQUAL(
+ int(1411), static_cast<int>(rEditView2.GetAttribs().Get(EE_CHAR_FONTHEIGHT).GetHeight()));
}
void SdTiledRenderingTest::testPostKeyEventInvalidation()