summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2024-08-26 17:35:08 +0100
committerCaolán McNamara <caolan.mcnamara@collabora.com>2024-08-26 22:15:04 +0200
commit023e284f7844c64f042a407fb6ecba80751068cf (patch)
tree0286a72a13a89697c447ebe6f8c43a53d67effe1 /sw
parenta2cbcb061d50cd8ac455a8eec2f1dafe0b46573a (diff)
cid#1557116 dangling reference
CreateFrameTabDialog takes an argument of a reference to the aSet ItemSet and SwFrameDlg keeps that reference but the SwFrameDlg will outlive that local. Change-Id: I9a0c55b86baf84cfa586952755e5a470a44562c7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172432 Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/uiwriter/uiwriter7.cxx4
-rw-r--r--sw/source/uibase/inc/textsh.hxx2
-rw-r--r--sw/source/uibase/shells/textsh.cxx34
3 files changed, 20 insertions, 20 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter7.cxx b/sw/qa/extras/uiwriter/uiwriter7.cxx
index 4cdfbc3e7a0c..1070f5f26652 100644
--- a/sw/qa/extras/uiwriter/uiwriter7.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter7.cxx
@@ -2463,10 +2463,10 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf88986)
// Create the item set that is normally passed to the insert frame dialog.
SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
SwFlyFrameAttrMgr aMgr(true, pWrtShell, Frmmgr_Type::TEXT, nullptr);
- SfxItemSet aSet = aShell.CreateInsertFrameItemSet(aMgr);
+ auto xSet = aShell.CreateInsertFrameItemSet(aMgr);
// This was missing along with the gradient and other tables.
- CPPUNIT_ASSERT(aSet.HasItem(SID_COLOR_TABLE));
+ CPPUNIT_ASSERT(xSet->HasItem(SID_COLOR_TABLE));
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf78150)
diff --git a/sw/source/uibase/inc/textsh.hxx b/sw/source/uibase/inc/textsh.hxx
index e0d962bf8293..1eb75edb43a0 100644
--- a/sw/source/uibase/inc/textsh.hxx
+++ b/sw/source/uibase/inc/textsh.hxx
@@ -83,7 +83,7 @@ public:
SwTextShell(SwView &rView);
virtual ~SwTextShell() override;
/// Create item set for the insert frame dialog.
- SfxItemSet CreateInsertFrameItemSet(SwFlyFrameAttrMgr& rMgr);
+ std::shared_ptr<SfxItemSet> CreateInsertFrameItemSet(SwFlyFrameAttrMgr& rMgr);
};
#endif
diff --git a/sw/source/uibase/shells/textsh.cxx b/sw/source/uibase/shells/textsh.cxx
index 97652924dfe8..4696335884aa 100644
--- a/sw/source/uibase/shells/textsh.cxx
+++ b/sw/source/uibase/shells/textsh.cxx
@@ -524,7 +524,7 @@ void SwTextShell::ExecInsert(SfxRequest &rReq)
}
else
{
- SfxItemSet aSet = CreateInsertFrameItemSet(aMgr);
+ auto xSet = CreateInsertFrameItemSet(aMgr);
FieldUnit eMetric = ::GetDfltMetric(dynamic_cast<SwWebDocShell*>( GetView().GetDocShell()) != nullptr );
SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
@@ -532,8 +532,8 @@ void SwTextShell::ExecInsert(SfxRequest &rReq)
VclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateFrameTabDialog(u"FrameDialog"_ustr,
GetView().GetViewFrame(),
GetView().GetFrameWeld(),
- aSet));
- pDlg->StartExecuteAsync([aSet, pDlg, nSlot, this](sal_Int32 nResult) {
+ *xSet));
+ pDlg->StartExecuteAsync([xSet=std::move(xSet), pDlg, nSlot, this](sal_Int32 nResult) {
if (nResult == RET_OK && pDlg->GetOutputItemSet())
{
SwFlyFrameAttrMgr aAttrMgr( true, GetShellPtr(), Frmmgr_Type::TEXT, nullptr );
@@ -544,7 +544,7 @@ void SwTextShell::ExecInsert(SfxRequest &rReq)
rShell.StartUndo(SwUndoId::INSERT);
SfxItemSet aOutSet(*pDlg->GetOutputItemSet());
- const SvxBoxItem* pBox = aSet.GetItem(RES_BOX);
+ const SvxBoxItem* pBox = xSet->GetItem(RES_BOX);
if (pBox && !aOutSet.HasItem(RES_BOX))
{
// The input set had border info but the output set not, then copy it over
@@ -921,9 +921,9 @@ SwTextShell::~SwTextShell()
{
}
-SfxItemSet SwTextShell::CreateInsertFrameItemSet(SwFlyFrameAttrMgr& rMgr)
+std::shared_ptr<SfxItemSet> SwTextShell::CreateInsertFrameItemSet(SwFlyFrameAttrMgr& rMgr)
{
- SfxItemSet aSet(GetPool(), svl::Items<
+ auto xSet = std::make_shared<SfxItemSet>(GetPool(), svl::Items<
RES_FRMATR_BEGIN, RES_FRMATR_END-1,
XATTR_FILL_FIRST, XATTR_FILL_LAST, // tdf#95003
SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
@@ -932,38 +932,38 @@ SfxItemSet SwTextShell::CreateInsertFrameItemSet(SwFlyFrameAttrMgr& rMgr)
SID_HTML_MODE, SID_HTML_MODE,
FN_GET_PRINT_AREA, FN_GET_PRINT_AREA,
FN_SET_FRM_NAME, FN_SET_FRM_NAME>);
- aSet.Put(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(GetView().GetDocShell())));
+ xSet->Put(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(GetView().GetDocShell())));
// For the Area tab page.
- GetShell().GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->PutAreaListItems(aSet);
+ GetShell().GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->PutAreaListItems(*xSet);
const SwRect &rPg = GetShell().GetAnyCurRect(CurRectType::Page);
SwFormatFrameSize aFrameSize(SwFrameSize::Variable, rPg.Width(), rPg.Height());
aFrameSize.SetWhich(GetPool().GetWhichIDFromSlotID(SID_ATTR_PAGE_SIZE));
- aSet.Put(aFrameSize);
+ xSet->Put(aFrameSize);
const SwRect &rPr = GetShell().GetAnyCurRect(CurRectType::PagePrt);
SwFormatFrameSize aPrtSize(SwFrameSize::Variable, rPr.Width(), rPr.Height());
aPrtSize.SetWhich(GetPool().GetWhichIDFromSlotID(FN_GET_PRINT_AREA));
- aSet.Put(aPrtSize);
+ xSet->Put(aPrtSize);
- aSet.Put(rMgr.GetAttrSet());
- aSet.SetParent( rMgr.GetAttrSet().GetParent() );
+ xSet->Put(rMgr.GetAttrSet());
+ xSet->SetParent( rMgr.GetAttrSet().GetParent() );
// Delete minimum size in columns.
- SvxBoxInfoItem aBoxInfo(aSet.Get(SID_ATTR_BORDER_INNER));
- const SvxBoxItem& rBox = aSet.Get(RES_BOX);
+ SvxBoxInfoItem aBoxInfo(xSet->Get(SID_ATTR_BORDER_INNER));
+ const SvxBoxItem& rBox = xSet->Get(RES_BOX);
aBoxInfo.SetMinDist(false);
aBoxInfo.SetDefDist(rBox.GetDistance(SvxBoxItemLine::LEFT));
- aSet.Put(aBoxInfo);
+ xSet->Put(aBoxInfo);
if (!SwFlyFrameAttrMgr::SingleTableSelected(GetShell()))
{
SwFormatAnchor aAnchor(RndStdIds::FLY_AT_CHAR);
- aSet.Put(aAnchor);
+ xSet->Put(aAnchor);
}
- return aSet;
+ return xSet;
}
void SwTextShell::InsertSymbol( SfxRequest& rReq )