From 507771e499cf3ea658781d4e044ea4400888e3a6 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 7 Jun 2019 17:20:34 +0200 Subject: Related: tdf#111522 svx: fix crash with view1 doing textedit and resize/rotate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The two actually affected functions are SdrEditView::RotateMarkedObj() and SdrDragObjOwn::EndSdrDrag(), but it looks like the other functions in SdrEditView are safe to be changed the same way. I expect IsUndoEnabled() can't be changed, though: that would mean there would be no undo for the text edit itself, either. If other actions still crash, the pattern is the same: put a breakpoint on the SdrUndoAction constructor and see the backtrace to find the function that calls IsUndoEnabled() without calling CanDoSdrUndo() at the same time. Change-Id: If9324e311ec6e9f68a951559e903e14bb72ea31c Reviewed-on: https://gerrit.libreoffice.org/73669 Reviewed-by: Miklos Vajna Tested-by: Jenkins (cherry picked from commit 9870ff897f088563426bee9567dd9cb722c2b929) Reviewed-on: https://gerrit.libreoffice.org/73748 Reviewed-by: Xisco FaulĂ­ (cherry picked from commit 79cae65f4725d0a8abd5639dc298002d11b2626c) Reviewed-on: https://gerrit.libreoffice.org/73757 --- svx/source/svdraw/svddrgmt.cxx | 2 +- svx/source/svdraw/svdedtv1.cxx | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'svx') diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx index cb0c3d1fa2c5..affd94e14bb6 100644 --- a/svx/source/svdraw/svddrgmt.cxx +++ b/svx/source/svdraw/svddrgmt.cxx @@ -1323,7 +1323,7 @@ bool SdrDragObjOwn::EndSdrDrag(bool /*bCopy*/) { std::unique_ptr pUndo; std::unique_ptr pUndo2; - const bool bUndo = getSdrDragView().IsUndoEnabled(); + const bool bUndo = getSdrDragView().IsUndoEnabled() && getSdrDragView().CanDoSdrUndo(); if( bUndo ) { diff --git a/svx/source/svdraw/svdedtv1.cxx b/svx/source/svdraw/svdedtv1.cxx index aa8e5d6df761..43f72e63369f 100644 --- a/svx/source/svdraw/svdedtv1.cxx +++ b/svx/source/svdraw/svdedtv1.cxx @@ -85,7 +85,7 @@ void SdrEditView::SetMarkedObjRect(const tools::Rectangle& rRect) long w1=rRect.Right()-x1; long h1=rRect.Bottom()-y1; - const bool bUndo = IsUndoEnabled(); + const bool bUndo = IsUndoEnabled() && CanDoSdrUndo(); if( bUndo ) BegUndo(ImpGetDescriptionString(STR_EditPosSize)); @@ -205,7 +205,7 @@ void SdrEditView::MoveMarkedObj(const Size& rSiz, bool bCopy) void SdrEditView::ResizeMarkedObj(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bCopy) { - const bool bUndo = IsUndoEnabled(); + const bool bUndo = IsUndoEnabled() && CanDoSdrUndo(); if( bUndo ) { OUString aStr {ImpGetDescriptionString(STR_EditResize)}; @@ -239,7 +239,7 @@ void SdrEditView::ResizeMultMarkedObj(const Point& rRef, const bool bWdh, const bool bHgt) { - const bool bUndo = IsUndoEnabled(); + const bool bUndo = IsUndoEnabled() && CanDoSdrUndo(); if( bUndo ) { BegUndo(ImpGetDescriptionString(STR_EditResize)); @@ -299,7 +299,7 @@ long SdrEditView::GetMarkedObjRotate() const void SdrEditView::RotateMarkedObj(const Point& rRef, long nAngle, bool bCopy) { - const bool bUndo = IsUndoEnabled(); + const bool bUndo = IsUndoEnabled() && CanDoSdrUndo(); if( bUndo ) { OUString aStr {ImpGetDescriptionString(STR_EditRotate)}; @@ -354,7 +354,7 @@ void SdrEditView::RotateMarkedObj(const Point& rRef, long nAngle, bool bCopy) void SdrEditView::MirrorMarkedObj(const Point& rRef1, const Point& rRef2, bool bCopy) { - const bool bUndo = IsUndoEnabled(); + const bool bUndo = IsUndoEnabled() && CanDoSdrUndo(); if( bUndo ) { @@ -453,7 +453,7 @@ long SdrEditView::GetMarkedObjShear() const void SdrEditView::ShearMarkedObj(const Point& rRef, long nAngle, bool bVShear, bool bCopy) { - const bool bUndo = IsUndoEnabled(); + const bool bUndo = IsUndoEnabled() && CanDoSdrUndo(); if( bUndo ) { @@ -566,7 +566,7 @@ void SdrEditView::CrookMarkedObj(const Point& rRef, const Point& rRad, SdrCrookM bool bVertical, bool bNoContortion, bool bCopy) { tools::Rectangle aMarkRect(GetMarkedObjRect()); - const bool bUndo = IsUndoEnabled(); + const bool bUndo = IsUndoEnabled() && CanDoSdrUndo(); bool bRotate=bNoContortion && eMode==SdrCrookMode::Rotate && IsRotateAllowed(); @@ -641,7 +641,7 @@ void SdrEditView::ImpDistortObj(SdrObject* pO, const tools::Rectangle& rRef, con void SdrEditView::DistortMarkedObj(const tools::Rectangle& rRef, const XPolygon& rDistortedRect, bool bNoContortion, bool bCopy) { - const bool bUndo = IsUndoEnabled(); + const bool bUndo = IsUndoEnabled() && CanDoSdrUndo(); if( bUndo ) { @@ -750,7 +750,7 @@ void SdrEditView::SetNotPersistAttrToMarked(const SfxItemSet& rAttr) ShearMarkedObj(aAllSnapRect.Center(),nAngle,true); } - const bool bUndo = IsUndoEnabled(); + const bool bUndo = IsUndoEnabled() && CanDoSdrUndo(); // TODO: check if WhichRange is necessary. const size_t nMarkCount=GetMarkedObjectCount(); @@ -998,7 +998,7 @@ void SdrEditView::SetAttrToMarked(const SfxItemSet& rAttr, bool bReplaceAll) nWhich = aIter.NextWhich(); } - const bool bUndo = IsUndoEnabled(); + const bool bUndo = IsUndoEnabled() && CanDoSdrUndo(); if( bUndo ) { BegUndo(ImpGetDescriptionString(STR_EditSetAttributes)); @@ -1176,7 +1176,7 @@ void SdrEditView::SetStyleSheetToMarked(SfxStyleSheet* pStyleSheet, bool bDontRe { if (AreObjectsMarked()) { - const bool bUndo = IsUndoEnabled(); + const bool bUndo = IsUndoEnabled() && CanDoSdrUndo(); if( bUndo ) { @@ -1729,7 +1729,7 @@ void SdrEditView::AlignMarkedObjects(SdrHorAlign eHor, SdrVertAlign eVert) if (!GetMarkedObjectCount()) return; - const bool bUndo = IsUndoEnabled(); + const bool bUndo = IsUndoEnabled() && CanDoSdrUndo(); if( bUndo ) { OUString aStr(GetDescriptionOfMarkedObjects()); -- cgit