diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2019-06-05 16:28:53 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2019-06-05 23:20:38 +0200 |
commit | 3a874f1c80c37e8b35666e1d73161ff762eb7e4c (patch) | |
tree | 1612df2e043979a60eb24ce6143dcbf5defc678d /svx | |
parent | c3ce652b4a2a5891fa5664a0ad0ee8cb14aef908 (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. ]
Change-Id: I3a364bf4fe6f9b0c13aa07283681b1045368cf7a
Reviewed-on: https://gerrit.libreoffice.org/73558
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/svdraw/svdedtv.cxx | 18 | ||||
-rw-r--r-- | svx/source/svdraw/svdedtv1.cxx | 2 |
2 files changed, 18 insertions, 2 deletions
diff --git a/svx/source/svdraw/svdedtv.cxx b/svx/source/svdraw/svdedtv.cxx index 51678b78b0d0..5883eab62640 100644 --- a/svx/source/svdraw/svdedtv.cxx +++ b/svx/source/svdraw/svdedtv.cxx @@ -972,7 +972,7 @@ bool SdrEditView::InsertObjectAtView(SdrObject* pObj, SdrPageView& rPV, SdrInser if (!pObj->IsInserted()) { rPV.GetObjList()->InsertObject(pObj, SAL_MAX_SIZE); } - if( IsUndoEnabled() ) + if( IsUndoEnabled() && CanDoSdrUndo()) AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pObj)); if (!(nOptions & SdrInsertFlags::DONTMARK)) { @@ -1028,4 +1028,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 f781b64b36f7..66bc4c15ae69 100644 --- a/svx/source/svdraw/svdedtv1.cxx +++ b/svx/source/svdraw/svdedtv1.cxx @@ -175,7 +175,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 ) { |