Kaydet (Commit) 1e21c32a authored tarafından Miklos Vajna's avatar Miklos Vajna

tdf#101168 sw: fix missing repaint on undo with multiple windows

Need to lock / unlock all view shells, not just the current one.

Change-Id: I754214a202c6bbb74daac6f933481cb3fe7b9dbb
Reviewed-on: https://gerrit.libreoffice.org/27620Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst 1b36d5f3
......@@ -58,6 +58,7 @@ public:
void testViewCursorCleanup();
void testViewLock();
void testTextEditViewInvalidations();
void testUndoInvalidations();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
......@@ -82,6 +83,7 @@ public:
CPPUNIT_TEST(testViewCursorCleanup);
CPPUNIT_TEST(testViewLock);
CPPUNIT_TEST(testTextEditViewInvalidations);
CPPUNIT_TEST(testUndoInvalidations);
CPPUNIT_TEST_SUITE_END();
private:
......@@ -854,6 +856,40 @@ void SwTiledRenderingTest::testTextEditViewInvalidations()
comphelper::LibreOfficeKit::setActive(false);
}
void SwTiledRenderingTest::testUndoInvalidations()
{
// Load a document and create two views.
comphelper::LibreOfficeKit::setActive();
SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
ViewCallback aView1;
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
SfxLokHelper::createView();
pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
ViewCallback aView2;
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2);
// Insert a character the end of the document.
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
pWrtShell->EndDoc();
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'c', 0);
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'c', 0);
SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false);
CPPUNIT_ASSERT_EQUAL(OUString("Aaa bbb.c"), pShellCursor->GetPoint()->nNode.GetNode().GetTextNode()->GetText());
// Undo and assert that both views are invalidated.
aView1.m_bTilesInvalidated = false;
aView2.m_bTilesInvalidated = false;
comphelper::dispatchCommand(".uno:Undo", {});
Scheduler::ProcessEventsToIdle();
CPPUNIT_ASSERT(aView1.m_bTilesInvalidated);
// Undo was dispatched on the first view, this second view was not invalidated.
CPPUNIT_ASSERT(aView2.m_bTilesInvalidated);
mxComponent->dispose();
mxComponent.clear();
comphelper::LibreOfficeKit::setActive(false);
}
CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT();
......
......@@ -489,15 +489,19 @@ void SwBaseShell::ExecUndo(SfxRequest &rReq)
switch( nId )
{
case SID_UNDO:
rWrtShell.LockPaint();
for (SwViewShell& rShell : rWrtShell.GetRingContainer())
rShell.LockPaint();
rWrtShell.Do( SwWrtShell::UNDO, nCnt );
rWrtShell.UnlockPaint();
for (SwViewShell& rShell : rWrtShell.GetRingContainer())
rShell.UnlockPaint();
break;
case SID_REDO:
rWrtShell.LockPaint();
for (SwViewShell& rShell : rWrtShell.GetRingContainer())
rShell.LockPaint();
rWrtShell.Do( SwWrtShell::REDO, nCnt );
rWrtShell.UnlockPaint();
for (SwViewShell& rShell : rWrtShell.GetRingContainer())
rShell.UnlockPaint();
break;
case SID_REPEAT:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment