summaryrefslogtreecommitdiff
path: root/sw/source/ui/table/colwd.cxx
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/ui/table/colwd.cxx
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/ui/table/colwd.cxx')
-rw-r--r--sw/source/ui/table/colwd.cxx27
1 files changed, 15 insertions, 12 deletions
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))));
}