summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-06-05 16:28:53 +0200
committerXisco FaulĂ­ <xiscofauli@libreoffice.org>2019-06-10 13:09:11 +0200
commit2980fa249a2680f32915de470a9cd8840780c2a0 (patch)
treec06c6867cc94181aac5f60d8e77815261cc5eb49 /svx
parentbc651b9157fa8f35e28774ffebda1bb7fadb455b (diff)
tdf#111522 svx: fix crash with view1 doing text edit and view2 doing sdr undo
If one view has an active text edit, then current code doesn't handle manipulating the undo text outside the text edit, so avoid problems by simply not adding an undo action to the undo stack for shape creation or move. Other actions might want to do the same in the future: check for CanDoSdrUndo() before calling SdrUndoFactory member functions. [ Found no existing test suite similar to CppunitTest_sw_uiwriter, so added one. ] (cherry picked from commit 3a874f1c80c37e8b35666e1d73161ff762eb7e4c) Change-Id: I3a364bf4fe6f9b0c13aa07283681b1045368cf7a Reviewed-on: https://gerrit.libreoffice.org/73649 Tested-by: Jenkins Reviewed-by: Xisco FaulĂ­ <xiscofauli@libreoffice.org>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/svdraw/svdedtv.cxx18
-rw-r--r--svx/source/svdraw/svdedtv1.cxx2
2 files changed, 18 insertions, 2 deletions
diff --git a/svx/source/svdraw/svdedtv.cxx b/svx/source/svdraw/svdedtv.cxx
index 2197c3fbc42e..e42e90fcedeb 100644
--- a/svx/source/svdraw/svdedtv.cxx
+++ b/svx/source/svdraw/svdedtv.cxx
@@ -977,7 +977,7 @@ bool SdrEditView::InsertObjectAtView(SdrObject* pObj, SdrPageView& rPV, SdrInser
rPV.GetObjList()->InsertObject(pObj, SAL_MAX_SIZE);
}
}
- if( IsUndoEnabled() )
+ if( IsUndoEnabled() && CanDoSdrUndo())
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pObj));
if (!(nOptions & SdrInsertFlags::DONTMARK)) {
@@ -1033,4 +1033,20 @@ bool SdrEditView::IsUndoEnabled() const
return mpModel->IsUndoEnabled();
}
+bool SdrEditView::CanDoSdrUndo() const
+{
+ size_t nViews = mpModel->GetListenerCount();
+ for (size_t nView = 0; nView < nViews; ++nView)
+ {
+ SdrEditView* pView = dynamic_cast<SdrEditView*>(mpModel->GetListener(nView));
+ if (!pView)
+ continue;
+
+ if (pView->IsTextEdit())
+ return false;
+ }
+
+ return true;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdedtv1.cxx b/svx/source/svdraw/svdedtv1.cxx
index 960dd2c58269..aa8e5d6df761 100644
--- a/svx/source/svdraw/svdedtv1.cxx
+++ b/svx/source/svdraw/svdedtv1.cxx
@@ -172,7 +172,7 @@ void SdrEditView::AddUndoActions( std::vector< std::unique_ptr<SdrUndoAction> >
void SdrEditView::MoveMarkedObj(const Size& rSiz, bool bCopy)
{
- const bool bUndo = IsUndoEnabled();
+ const bool bUndo = IsUndoEnabled() && CanDoSdrUndo();
if( bUndo )
{