tdf#159666 Crash when table and line object are selected at the same time
before
commit e3077168072452fb8f1c0a8afb2992877cb96d1c
Author: Noel Grandin <noel.grandin@collabora.co.uk>
Date: Thu Jun 17 09:49:37 2021 +0200
loplugin:finalclasses
the cast in
const SdrEdgeObj* pEdge = static_cast<SdrEdgeObj*>(m_pObj);
would incorrectly cast a SdrTableObj, but it happened to do nothing
problematic.
After the above commit, the vtable layout changed and it started
crashing.
Work around it by use dynamic_cast and ignoring objects that are not
SdrEdgeObj.
Change-Id: Ibe03d4935b8eeb182e037b1648d841e26fa23ed4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163242
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
(cherry picked from commit bac09f76fd903c109b591a7bc15883e5653715ee)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163187
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
(cherry picked from commit 12b25cb35eb9cbb08363f4bd45e9190d3ef674b5)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163270
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/svx/source/svdraw/svdhdl.cxx b/svx/source/svdraw/svdhdl.cxx
index 867afa6..c8f1fa3 100644
--- a/svx/source/svdraw/svdhdl.cxx
+++ b/svx/source/svdraw/svdhdl.cxx
@@ -1604,66 +1604,67 @@ ImpEdgeHdl::~ImpEdgeHdl()
void ImpEdgeHdl::CreateB2dIAObject()
{
if(m_nObjHdlNum <= 1 && m_pObj)
{
// first throw away old one
GetRidOfIAObject();
BitmapColorIndex eColIndex = BitmapColorIndex::LightCyan;
BitmapMarkerKind eKindOfMarker = BitmapMarkerKind::Rect_7x7;
if(m_pHdlList)
{
SdrMarkView* pView = m_pHdlList->GetView();
if(pView && !pView->areMarkHandlesHidden())
{
const SdrEdgeObj* pEdge = static_cast<SdrEdgeObj*>(m_pObj);
if(pEdge->GetConnectedNode(m_nObjHdlNum == 0) != nullptr)
eColIndex = BitmapColorIndex::LightRed;
if(m_nPPntNum < 2)
{
// Handle with plus sign inside
eKindOfMarker = BitmapMarkerKind::Circ_7x7;
}
SdrPageView* pPageView = pView->GetSdrPageView();
if(pPageView)
{
for(sal_uInt32 b(0); b < pPageView->PageWindowCount(); b++)
{
const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
if(rPageWindow.GetPaintWindow().OutputToWindow())
{
const rtl::Reference< sdr::overlay::OverlayManager >& xManager = rPageWindow.GetOverlayManager();
if (xManager.is())
{
basegfx::B2DPoint aPosition(m_aPos.X(), m_aPos.Y());
std::unique_ptr<sdr::overlay::OverlayObject> pNewOverlayObject(CreateOverlayObject(
aPosition,
eColIndex,
eKindOfMarker));
// OVERLAYMANAGER
insertNewlyCreatedOverlayObjectForSdrHdl(
std::move(pNewOverlayObject),
rPageWindow.GetObjectContact(),
*xManager);
}
}
}
}
}
}
}
else
if(m_nObjHdlNum > 1 || !m_pObj)
{
// call parent
SdrHdl::CreateB2dIAObject();
return;
}
// first throw away old one
GetRidOfIAObject();
BitmapColorIndex eColIndex = BitmapColorIndex::LightCyan;
BitmapMarkerKind eKindOfMarker = BitmapMarkerKind::Rect_7x7;
if(!m_pHdlList)
return;
SdrMarkView* pView = m_pHdlList->GetView();
if(!pView || pView->areMarkHandlesHidden())
return;
// tdf#159666 Crash when table and line object are selected at the same time
auto pEdge = dynamic_cast<SdrEdgeObj*>(m_pObj);
if (!pEdge)
return;
if(pEdge->GetConnectedNode(m_nObjHdlNum == 0) != nullptr)
eColIndex = BitmapColorIndex::LightRed;
if(m_nPPntNum < 2)
{
// Handle with plus sign inside
eKindOfMarker = BitmapMarkerKind::Circ_7x7;
}
SdrPageView* pPageView = pView->GetSdrPageView();
if(!pPageView)
return;
for(sal_uInt32 b(0); b < pPageView->PageWindowCount(); b++)
{
const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
if(rPageWindow.GetPaintWindow().OutputToWindow())
{
const rtl::Reference< sdr::overlay::OverlayManager >& xManager = rPageWindow.GetOverlayManager();
if (xManager.is())
{
basegfx::B2DPoint aPosition(m_aPos.X(), m_aPos.Y());
std::unique_ptr<sdr::overlay::OverlayObject> pNewOverlayObject(CreateOverlayObject(
aPosition,
eColIndex,
eKindOfMarker));
// OVERLAYMANAGER
insertNewlyCreatedOverlayObjectForSdrHdl(
std::move(pNewOverlayObject),
rPageWindow.GetObjectContact(),
*xManager);
}
}
}
}