tdf#173510 sw: prevent crash when table style deselected
This fixes a 26.8 regression that can cause LO to crash, from commit2f16debb36. A -1 is possible! Hold down the Ctrl key to deselect the selected table style. Since GetData requires a valid index, the -1 crashes the lookup. The assert was added by Caolan just to silence warnings. It OUGHT to be possible to have a -1, so we desperately need to handle it. One side effect of the -1 is that the preview window needs to be updated. So that change is included in this patch. It basically ends up being a partial revert of2f16debb36. P.S. I don't know how m_xTAutoFormat would already have a value, but that has been like that since introduction, so I decided not to fiddle with it. But surely you cannot run the OKHdl more than once... Change-Id: Ieae175072c17b20e79a139b434eae2fed09ca655 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/211917 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com>
This commit is contained in:
@@ -150,19 +150,27 @@ IMPL_LINK_NOARG(SwInsTableDlg, SelFormatHdl, weld::ItemView&, void)
|
||||
{
|
||||
// Get index of selected item from the listbox
|
||||
int styleIdx = m_xLbFormat->get_selected_index();
|
||||
assert(styleIdx != -1 && "nothing selected");
|
||||
m_aWndPreview.NotifyChange(m_xTableTable->GetResolvedStyle(m_xTableTable->GetData(styleIdx)));
|
||||
if (styleIdx == -1)
|
||||
{
|
||||
SwTableAutoFormat aNone(TableStyleName(SwViewShell::GetShellRes()->aStrNone));
|
||||
aNone.DisableAll();
|
||||
m_aWndPreview.NotifyChange(&aNone);
|
||||
}
|
||||
else
|
||||
m_aWndPreview.NotifyChange(m_xTableTable->GetResolvedStyle(
|
||||
m_xTableTable->GetData(styleIdx)));
|
||||
}
|
||||
|
||||
IMPL_LINK_NOARG(SwInsTableDlg, OKHdl, weld::Button&, void)
|
||||
{
|
||||
int styleIdx = m_xLbFormat->get_selected_index();
|
||||
assert(styleIdx != -1 && "nothing selected");
|
||||
|
||||
if( m_xTAutoFormat )
|
||||
*m_xTAutoFormat = (*m_xTableTable)[styleIdx];
|
||||
else
|
||||
m_xTAutoFormat.reset(new SwTableAutoFormat((*m_xTableTable)[styleIdx]));
|
||||
if (styleIdx != -1)
|
||||
{
|
||||
if (m_xTAutoFormat)
|
||||
*m_xTAutoFormat = (*m_xTableTable)[styleIdx];
|
||||
else
|
||||
m_xTAutoFormat.reset(new SwTableAutoFormat((*m_xTableTable)[styleIdx]));
|
||||
}
|
||||
|
||||
m_xDialog->response(RET_OK);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user