summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2024-04-16 15:08:33 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2024-04-16 18:34:09 +0200
commit0fa363faaba5dc9c57cf7fd1d4aa0dd300310682 (patch)
treedd763fa5884ee036cd725d820d71d679d2977751 /sw/source
parent1e1a3825d76ed8071424e8e21bbda23464c10fff (diff)
tdf#160632 TABLE: Crash when using column width dialog
regression from commit a08110be32a6958f27ce9ddb1e2cb2227265dfe1 Author: Noel Grandin <noel.grandin@collabora.co.uk> Date: Tue Jan 30 12:24:47 2024 +0200 convert table width dialog to async we were referencing an object that had already been destroyed by the time the dialog completed Change-Id: I2a06dd99129b53c558d6f5f3f96fc16dcc04f754 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166147 Tested-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/ui/dialog/swdlgfact.cxx4
-rw-r--r--sw/source/ui/dialog/swdlgfact.hxx2
-rw-r--r--sw/source/ui/table/colwd.cxx27
-rw-r--r--sw/source/uibase/inc/tablemgr.hxx1
-rw-r--r--sw/source/uibase/shells/tabsh.cxx13
-rw-r--r--sw/source/uibase/table/tablemgr.cxx16
6 files changed, 29 insertions, 34 deletions
diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx
index 415bf658b3c3..42a46be6858f 100644
--- a/sw/source/ui/dialog/swdlgfact.cxx
+++ b/sw/source/ui/dialog/swdlgfact.cxx
@@ -1223,9 +1223,9 @@ VclPtr<SfxAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwWrapDlg(weld::Wi
return VclPtr<SwAbstractSfxController_Impl>::Create(std::make_unique<SwWrapDlg>(pParent, rSet, pSh, true/*bDrawMode*/));
}
-VclPtr<AbstractSwTableWidthDlg> SwAbstractDialogFactory_Impl::CreateSwTableWidthDlg(weld::Window *pParent, SwTableFUNC &rFnc)
+VclPtr<AbstractSwTableWidthDlg> SwAbstractDialogFactory_Impl::CreateSwTableWidthDlg(weld::Window *pParent, SwWrtShell *pShell)
{
- return VclPtr<AbstractSwTableWidthDlg_Impl>::Create(std::make_unique<SwTableWidthDlg>(pParent, rFnc));
+ return VclPtr<AbstractSwTableWidthDlg_Impl>::Create(std::make_unique<SwTableWidthDlg>(pParent, pShell));
}
VclPtr<SfxAbstractTabDialog> SwAbstractDialogFactory_Impl::CreateSwTableTabDlg(weld::Window* pParent,
diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx
index f94342e23b31..4fc2cea421a3 100644
--- a/sw/source/ui/dialog/swdlgfact.hxx
+++ b/sw/source/ui/dialog/swdlgfact.hxx
@@ -832,7 +832,7 @@ public:
virtual VclPtr<SfxAbstractDialog> CreateSwBorderDlg(weld::Window* pParent, SfxItemSet& rSet, SwBorderModes nType) override;
virtual VclPtr<SfxAbstractDialog> CreateSwWrapDlg(weld::Window* pParent, const SfxItemSet& rSet, SwWrtShell* pSh) override;
- virtual VclPtr<AbstractSwTableWidthDlg> CreateSwTableWidthDlg(weld::Window *pParent, SwTableFUNC &rFnc) override;
+ virtual VclPtr<AbstractSwTableWidthDlg> CreateSwTableWidthDlg(weld::Window *pParent, SwWrtShell *pShell) override;
virtual VclPtr<SfxAbstractTabDialog> CreateSwTableTabDlg(weld::Window* pParent,
const SfxItemSet* pItemSet, SwWrtShell* pSh) override;
virtual VclPtr<AbstractSwFieldDlg> CreateSwFieldDlg(SfxBindings* pB, SwChildWinWrapper* pCW, weld::Window *pParent) override;
diff --git a/sw/source/ui/table/colwd.cxx b/sw/source/ui/table/colwd.cxx
index 70e47e19c9ed..65d225050555 100644
--- a/sw/source/ui/table/colwd.cxx
+++ b/sw/source/ui/table/colwd.cxx
@@ -29,38 +29,41 @@
IMPL_LINK_NOARG(SwTableWidthDlg, LoseFocusHdl, weld::SpinButton&, void)
{
sal_uInt16 nId = o3tl::narrowing<sal_uInt16>(m_xColNF->get_value()) - 1;
- const SwTwips lWidth = m_rFnc.GetColWidth(nId);
- m_xWidthMF->set_max(m_xWidthMF->normalize(m_rFnc.GetMaxColWidth(nId)), FieldUnit::TWIP);
+ const SwTwips lWidth = m_xFnc->GetColWidth(nId);
+ m_xWidthMF->set_max(m_xWidthMF->normalize(m_xFnc->GetMaxColWidth(nId)), FieldUnit::TWIP);
m_xWidthMF->set_value(m_xWidthMF->normalize(lWidth), FieldUnit::TWIP);
}
-SwTableWidthDlg::SwTableWidthDlg(weld::Window *pParent, SwTableFUNC &rTableFnc)
+SwTableWidthDlg::SwTableWidthDlg(weld::Window *pParent, SwWrtShell *pShell)
: GenericDialogController(pParent, "modules/swriter/ui/columnwidth.ui", "ColumnWidthDialog")
- , m_rFnc(rTableFnc)
+ , m_xFnc(new SwTableFUNC(pShell))
, m_xColNF(m_xBuilder->weld_spin_button("column"))
, m_xWidthMF(m_xBuilder->weld_metric_spin_button("width", FieldUnit::CM))
{
- bool bIsWeb = rTableFnc.GetShell()
+ m_xFnc->InitTabCols();
+ bool bIsWeb = m_xFnc->GetShell()
&& (dynamic_cast< const SwWebDocShell* >(
- rTableFnc.GetShell()->GetView().GetDocShell()) != nullptr );
+ m_xFnc->GetShell()->GetView().GetDocShell()) != nullptr );
FieldUnit eFieldUnit = SW_MOD()->GetUsrPref( bIsWeb )->GetMetric();
::SetFieldUnit(*m_xWidthMF, eFieldUnit);
- m_xColNF->set_max(m_rFnc.GetColCount() + 1);
- m_xColNF->set_value(m_rFnc.GetCurColNum() + 1);
+ m_xColNF->set_max(m_xFnc->GetColCount() + 1);
+ m_xColNF->set_value(m_xFnc->GetCurColNum() + 1);
- if (m_rFnc.GetColCount() == 0)
- m_xWidthMF->set_min(m_xWidthMF->normalize(m_rFnc.GetColWidth(0)), FieldUnit::TWIP);
+ if (m_xFnc->GetColCount() == 0)
+ m_xWidthMF->set_min(m_xWidthMF->normalize(m_xFnc->GetColWidth(0)), FieldUnit::TWIP);
else
m_xWidthMF->set_min(m_xWidthMF->normalize(MINLAY), FieldUnit::TWIP);
m_xColNF->connect_value_changed(LINK(this, SwTableWidthDlg, LoseFocusHdl));
LoseFocusHdl(*m_xColNF);
}
+SwTableWidthDlg::~SwTableWidthDlg() {}
+
void SwTableWidthDlg::Apply()
{
- m_rFnc.InitTabCols();
- m_rFnc.SetColWidth(o3tl::narrowing<sal_uInt16>(m_xColNF->get_value() - 1),
+ m_xFnc->InitTabCols();
+ m_xFnc->SetColWidth(o3tl::narrowing<sal_uInt16>(m_xColNF->get_value() - 1),
o3tl::narrowing<sal_uInt16>(m_xWidthMF->denormalize(m_xWidthMF->get_value(FieldUnit::TWIP))));
}
diff --git a/sw/source/uibase/inc/tablemgr.hxx b/sw/source/uibase/inc/tablemgr.hxx
index d382d29b6c6e..96b1c34f350b 100644
--- a/sw/source/uibase/inc/tablemgr.hxx
+++ b/sw/source/uibase/inc/tablemgr.hxx
@@ -53,7 +53,6 @@ public:
~SwTableFUNC();
void InitTabCols();
- void ColWidthDlg(weld::Window *pParent);
SwTwips GetColWidth(sal_uInt16 nNum) const;
SwTwips GetMaxColWidth(sal_uInt16 nNum) const;
void SetColWidth(sal_uInt16 nNum, SwTwips nWidth );
diff --git a/sw/source/uibase/shells/tabsh.cxx b/sw/source/uibase/shells/tabsh.cxx
index 4d390e6a6a19..63857cfea12f 100644
--- a/sw/source/uibase/shells/tabsh.cxx
+++ b/sw/source/uibase/shells/tabsh.cxx
@@ -1349,8 +1349,17 @@ void SwTableShell::Execute(SfxRequest &rReq)
// The last case branch which needs a table manager!!
case FN_TABLE_SET_COL_WIDTH:
{
- SwTableFUNC aMgr( &rSh );
- aMgr.ColWidthDlg(GetView().GetFrameWeld());
+ // Adjust line height (dialogue)
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ VclPtr<AbstractSwTableWidthDlg> pDlg(pFact->CreateSwTableWidthDlg(GetView().GetFrameWeld(), &rSh));
+ pDlg->StartExecuteAsync(
+ [pDlg] (sal_Int32 nResult)->void
+ {
+ if (nResult == RET_OK)
+ pDlg->Apply();
+ pDlg->disposeOnce();
+ }
+ );
break;
}
case SID_TABLE_VERT_NONE:
diff --git a/sw/source/uibase/table/tablemgr.cxx b/sw/source/uibase/table/tablemgr.cxx
index 852d9d5585f2..ea2983279736 100644
--- a/sw/source/uibase/table/tablemgr.cxx
+++ b/sw/source/uibase/table/tablemgr.cxx
@@ -45,22 +45,6 @@
using namespace ::com::sun::star;
-// Adjust line height (dialogue)
-void SwTableFUNC::ColWidthDlg(weld::Window *pParent)
-{
- InitTabCols();
- SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
- VclPtr<AbstractSwTableWidthDlg> pDlg(pFact->CreateSwTableWidthDlg(pParent, *this));
- pDlg->StartExecuteAsync(
- [pDlg] (sal_Int32 nResult)->void
- {
- if (nResult == RET_OK)
- pDlg->Apply();
- pDlg->disposeOnce();
- }
- );
-}
-
// Determine the width
SwTwips SwTableFUNC::GetColWidth(sal_uInt16 nNum) const
{