summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2024-02-12 12:54:06 +0200
committerChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>2024-02-15 21:39:59 +0100
commit8e60f14eddf768db6ae0880ea6a8e6c834842582 (patch)
tree46b75a71284e9e05cbf4379b2820ea04b33ac4e5 /svx
parent5976bff00ae8eceedd139fbbb2621240108a2400 (diff)
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> Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163256 (cherry picked from commit 39efb3e139ae6423ea093eedc449ac8c5b2cebf4) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163277 Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de> Tested-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/svdraw/svdhdl.cxx101
1 files changed, 51 insertions, 50 deletions
diff --git a/svx/source/svdraw/svdhdl.cxx b/svx/source/svdraw/svdhdl.cxx
index 64f29976f5ca..62851f9b6331 100644
--- a/svx/source/svdraw/svdhdl.cxx
+++ b/svx/source/svdraw/svdhdl.cxx
@@ -1604,66 +1604,67 @@ ImpEdgeHdl::~ImpEdgeHdl()
void ImpEdgeHdl::CreateB2dIAObject()
{
- if(nObjHdlNum <= 1 && pObj)
+ if(nObjHdlNum > 1 || !pObj)
{
- // first throw away old one
- GetRidOfIAObject();
+ // call parent
+ SdrHdl::CreateB2dIAObject();
+ return;
+ }
- BitmapColorIndex eColIndex = BitmapColorIndex::LightCyan;
- BitmapMarkerKind eKindOfMarker = BitmapMarkerKind::Rect_7x7;
+ // first throw away old one
+ GetRidOfIAObject();
- if(pHdlList)
- {
- SdrMarkView* pView = pHdlList->GetView();
+ BitmapColorIndex eColIndex = BitmapColorIndex::LightCyan;
+ BitmapMarkerKind eKindOfMarker = BitmapMarkerKind::Rect_7x7;
- if(pView && !pView->areMarkHandlesHidden())
- {
- const SdrEdgeObj* pEdge = static_cast<SdrEdgeObj*>(pObj);
+ if(!pHdlList)
+ return;
- if(pEdge->GetConnectedNode(nObjHdlNum == 0) != nullptr)
- eColIndex = BitmapColorIndex::LightRed;
+ SdrMarkView* pView = pHdlList->GetView();
- if(nPPntNum < 2)
- {
- // Handle with plus sign inside
- eKindOfMarker = BitmapMarkerKind::Circ_7x7;
- }
+ if(!pView || pView->areMarkHandlesHidden())
+ return;
- SdrPageView* pPageView = pView->GetSdrPageView();
+ // tdf#159666 Crash when table and line object are selected at the same time
+ auto pEdge = dynamic_cast<SdrEdgeObj*>(pObj);
+ if (!pEdge)
+ return;
- 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(aPos.X(), aPos.Y());
- std::unique_ptr<sdr::overlay::OverlayObject> pNewOverlayObject(CreateOverlayObject(
- aPosition,
- eColIndex,
- eKindOfMarker));
-
- // OVERLAYMANAGER
- insertNewlyCreatedOverlayObjectForSdrHdl(
- std::move(pNewOverlayObject),
- rPageWindow.GetObjectContact(),
- *xManager);
- }
- }
- }
- }
- }
- }
+ if(pEdge->GetConnectedNode(nObjHdlNum == 0) != nullptr)
+ eColIndex = BitmapColorIndex::LightRed;
+
+ if(nPPntNum < 2)
+ {
+ // Handle with plus sign inside
+ eKindOfMarker = BitmapMarkerKind::Circ_7x7;
}
- else
+
+ SdrPageView* pPageView = pView->GetSdrPageView();
+ if(!pPageView)
+ return;
+
+ for(sal_uInt32 b(0); b < pPageView->PageWindowCount(); b++)
{
- // call parent
- SdrHdl::CreateB2dIAObject();
+ 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(aPos.X(), aPos.Y());
+ std::unique_ptr<sdr::overlay::OverlayObject> pNewOverlayObject(CreateOverlayObject(
+ aPosition,
+ eColIndex,
+ eKindOfMarker));
+
+ // OVERLAYMANAGER
+ insertNewlyCreatedOverlayObjectForSdrHdl(
+ std::move(pNewOverlayObject),
+ rPageWindow.GetObjectContact(),
+ *xManager);
+ }
+ }
}
}