From a91ab152a8ca911b7f75723a59a402bac6d9b05b Mon Sep 17 00:00:00 2001 From: László Németh Date: Wed, 13 Oct 2021 08:56:02 +0200 Subject: tdf#145093 sw track changes: fix crash at moving list items MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit over a tracked paragraph insertion (both in Show Changes and Hide Changes modes). Note: we needed a Python UI test, because uiwriter doesn't crash on Linux without this fix. Likely regression from commit a19dc0d9cc35ae1e200f51d86950595f6771e9c3 "sw_redlinehide_3: update frames in MoveParagraph()". Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123551 Tested-by: László Németh Reviewed-by: László Németh (cherry picked from commit eda5ac4a63fac6bce939b6791dec52270618dc29) Change-Id: I3026c9136e2fa6dcc1f6b5bad1677846a6cfe614 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126951 Tested-by: Michael Stahl Reviewed-by: Michael Stahl --- sw/qa/uitest/data/tdf39721.fodt | 42 ++++++++++++++++++++++ sw/qa/uitest/writer_tests7/tdf145093.py | 34 ++++++++++++++++++ .../core/doc/DocumentContentOperationsManager.cxx | 6 ++-- 3 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 sw/qa/uitest/data/tdf39721.fodt create mode 100644 sw/qa/uitest/writer_tests7/tdf145093.py diff --git a/sw/qa/uitest/data/tdf39721.fodt b/sw/qa/uitest/data/tdf39721.fodt new file mode 100644 index 000000000000..1acf06c5e2a5 --- /dev/null +++ b/sw/qa/uitest/data/tdf39721.fodt @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + Unknown Author + 2021-01-06T16:18:57 + + + + + + + Unknown Author + 2021-01-06T16:20:17 + + + + + + + Lorem ipsum + + + dolor sit + + + amet. + + + + + diff --git a/sw/qa/uitest/writer_tests7/tdf145093.py b/sw/qa/uitest/writer_tests7/tdf145093.py new file mode 100644 index 000000000000..c22510a619cc --- /dev/null +++ b/sw/qa/uitest/writer_tests7/tdf145093.py @@ -0,0 +1,34 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import select_pos +from uitest.uihelper.common import type_text +from uitest.uihelper.common import get_url_for_data_file + +class tdf145093(UITestCase): + def test_tdf145093(self): + # load the sample file + with self.ui_test.load_file(get_url_for_data_file("tdf39721.fodt")) as document: + + # redlining should be on + self.xUITest.executeCommand(".uno:TrackChanges") + + # Move Up/Down a list item over a tracked paragraph insertion resulted a crash + # (Note: not only at the end of the document, but check the original + # bug report temporarily, where the problem is triggered by an other problem). + + self.xUITest.executeCommand(".uno:MoveDown") + self.xUITest.executeCommand(".uno:MoveDown") + # Note: Move list item from the end of the document creates an extra insertion. + # TODO: fix this other problem, and improve the test with an extra paragraph insertion + self.xUITest.executeCommand(".uno:MoveUp") + + # This was a crash (using invalid pointer) both in Show Changes and Hide Changes modes + self.xUITest.executeCommand(".uno:MoveDown") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index 0199260aa6cf..5afadfff3de8 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -935,8 +935,10 @@ namespace for(SaveRedline & rSvRedLine : rArr) { rSvRedLine.SetPos( nInsPos ); - pDoc->getIDocumentRedlineAccess().AppendRedline( rSvRedLine.pRedl, true ); - if (rSvRedLine.pRedl->GetType() == RedlineType::Delete) + IDocumentRedlineAccess::AppendResult const result( + pDoc->getIDocumentRedlineAccess().AppendRedline( rSvRedLine.pRedl, true )); + if ( IDocumentRedlineAccess::AppendResult::APPENDED == result && + rSvRedLine.pRedl->GetType() == RedlineType::Delete ) { UpdateFramesForAddDeleteRedline(*pDoc, *rSvRedLine.pRedl); } -- cgit