[Libreoffice-commits] core.git: 2 commits - sd/qa svx/source
Michael Stahl
mstahl at redhat.com
Wed May 3 20:45:40 UTC 2017
sd/qa/unit/tiledrendering/tiledrendering.cxx | 2 ++
svx/source/svdraw/svdedxv.cxx | 17 +++++++++--------
2 files changed, 11 insertions(+), 8 deletions(-)
New commits:
commit 72097be9ca128083ed5b1cf5a5166ea7419891c5
Author: Michael Stahl <mstahl at redhat.com>
Date: Wed May 3 22:03:10 2017 +0200
svx: SdrObjEditView::SdrEndTextEdit() must be called after SdrBeginTextEdit()
... to prevent disasters with managing the UndoManager, so assert that.
Change-Id: Id577ea465e21e3d358b3ff0bb36de0af34e0b69d
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 08e1bc197dd6..6242349d3ce0 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -1333,6 +1333,7 @@ void SdTiledRenderingTest::testTdf102223()
uno::Sequence<beans::PropertyValue> aArgs;
comphelper::dispatchCommand(".uno:Cut", aArgs);
+ pView->SdrEndTextEdit(false);
pView->SdrBeginTextEdit(pTableObject);
CPPUNIT_ASSERT(pView->GetTextEditObject());
EditView& rEditView2 = pView->GetTextEditOutlinerView()->GetEditView();
@@ -1489,6 +1490,7 @@ void SdTiledRenderingTest::testTdf104405()
// now click on the table
pView->MarkObj(pTableObject, pView->GetSdrPageView());
pTableObject->setActiveCell(sdr::table::CellPos(0,0));
+ pView->SdrEndTextEdit(false);
pView->SdrBeginTextEdit(pTableObject);
EditView& rEditView2 = pView->GetTextEditOutlinerView()->GetEditView();
rEditView2.SetSelection(ESelection(0, 0, 0, 3)); // start para, start char, end para, end char.
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index 0e7f9ec3543a..1552591e1b38 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -97,6 +97,7 @@ SdrObjEditView::SdrObjEditView(SdrModel* pModel1, OutputDevice* pOut):
SdrObjEditView::~SdrObjEditView()
{
pTextEditWin = nullptr; // so there's no ShowCursor in SdrEndTextEdit
+ assert(!IsTextEdit());
if (IsTextEdit())
SdrEndTextEdit();
delete pTextEditOutliner;
@@ -707,6 +708,8 @@ bool SdrObjEditView::SdrBeginTextEdit(
bool bDontDeleteOutliner, bool bOnlyOneView,
bool bGrabFocus)
{
+ assert(!IsTextEdit());
+ // FIXME this encourages all sorts of bad habits and should be removed
SdrEndTextEdit();
if( dynamic_cast< SdrTextObj* >( pObj ) == nullptr )
commit f5a89dac29f745527ed8c437d4a138ebd0f2f4f8
Author: Michael Stahl <mstahl at redhat.com>
Date: Wed May 3 21:58:37 2017 +0200
svx: SdrObjEditView is not the owner of mpOldTextEditUndoManager
In all of sc, sd, sw, the UndoManager returned by
getSdrUndoManagerForEnhancedTextEdit() is owned by the application
and SdrObjEditView should leave its grubby paws off of it.
Change-Id: I7be3d336e0aaf4905323c1e99ff0643b3844f295
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index c49fd72c03af..0e7f9ec3543a 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -100,7 +100,7 @@ SdrObjEditView::~SdrObjEditView()
if (IsTextEdit())
SdrEndTextEdit();
delete pTextEditOutliner;
- delete mpOldTextEditUndoManager;
+ assert(nullptr == mpOldTextEditUndoManager); // should have been reset
}
@@ -952,13 +952,7 @@ bool SdrObjEditView::SdrBeginTextEdit(
// we have an outliner, undo manager and it's an EditUndoManager, exchange
// the document undo manager and the default one from the outliner and tell
// it that text edit starts by setting a callback if it needs to end text edit mode.
- if(mpOldTextEditUndoManager)
- {
- // should not happen, delete it since it was probably forgotten somewhere
- OSL_ENSURE(false, "Deleting forgotten old TextEditUndoManager, should be checked (!)");
- delete mpOldTextEditUndoManager;
- mpOldTextEditUndoManager = nullptr;
- }
+ assert(nullptr == mpOldTextEditUndoManager);
mpOldTextEditUndoManager = pTextEditOutliner->SetUndoManager(pSdrUndoManager);
pSdrUndoManager->SetEndTextEditHdl(LINK(this, SdrObjEditView, EndTextEditHdl));
@@ -1065,6 +1059,10 @@ SdrEndTextEditKind SdrObjEditView::SdrEndTextEdit(bool bDontDeleteReally)
}
}
}
+ else
+ {
+ assert(nullptr == mpOldTextEditUndoManager); // cannot be restored!
+ }
if( GetModel() && mxTextEditObj.is() )
{
More information about the Libreoffice-commits
mailing list