summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2022-11-03 09:14:18 +0100
committerStephan Bergmann <sbergman@redhat.com>2022-11-03 13:58:13 +0100
commite0121b2478526d803681d57d59af0cbf9cf602b4 (patch)
treeef7862c87934a2a2e2dd5f1a0c8fcec216c5fd4a
parentd40d64da771427423786dc62a2f4ad08cab53179 (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>
-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 aacb01522f51..ee2f47254765 100644
--- a/editeng/source/accessibility/AccessibleEditableTextPara.cxx
+++ b/editeng/source/accessibility/AccessibleEditableTextPara.cxx
@@ -1505,8 +1505,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 ec796f4a8521..5d2e5a2e4019 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 0fd33f62ed6d..bdd0d32d551b 100644
--- a/sc/source/ui/view/editsh.cxx
+++ b/sc/source/ui/view/editsh.cxx
@@ -383,8 +383,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 3529290162c9..a7e9095ed950 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -1490,8 +1490,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;
@@ -1502,8 +1502,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::testTdf118354()