aa67036
From d68cbde9a23d8ac68916b49d0cbcc5a4c2147b37 Mon Sep 17 00:00:00 2001
aa67036
From: Michael Stahl <mstahl@redhat.com>
aa67036
Date: Wed, 19 Sep 2012 20:47:48 +0200
aa67036
Subject: [PATCH 2/4] rhbz#689053: fix crash following delete at last table
aa67036
 cell:
aa67036
aa67036
The IsSelOvr() in SwCrsrShell::Combine() detects that the PaM with mark
aa67036
in the last table cell and point ouside the table is invalid, but
aa67036
unfortunatley restores the wrong position, which does not actually
aa67036
correct the PaM; the deletion on the invalid PaM then removes the
aa67036
last SwTxtNode in the document, which leads to crash later.
aa67036
aa67036
(cherry picked from commit af4b6c94c68b5f67b931cde8d0acda6ec8b288bb)
aa67036
aa67036
Conflicts:
aa67036
	sw/source/core/crsr/crsrsh.cxx
aa67036
aa67036
Change-Id: Ib2ae0b54e6c15dbe5b6811d8696531bf2022e1a4
aa67036
Reviewed-on: https://gerrit.libreoffice.org/652
aa67036
Reviewed-by: Miklos Vajna <vmiklos@suse.cz>
aa67036
Tested-by: Miklos Vajna <vmiklos@suse.cz>
aa67036
(cherry picked from commit 6bcbf68b29b609cf06dbea0e192533e11eb523c3)
aa67036
---
aa67036
 sw/source/core/crsr/crsrsh.cxx | 15 ++++++++-------
aa67036
 1 file changed, 8 insertions(+), 7 deletions(-)
aa67036
aa67036
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
aa67036
index 36fe86d..626557c 100644
aa67036
--- a/sw/source/core/crsr/crsrsh.cxx
aa67036
+++ b/sw/source/core/crsr/crsrsh.cxx
aa67036
@@ -1994,26 +1994,27 @@ void SwCrsrShell::Combine()
aa67036
         return;
aa67036
 
aa67036
     SwCallLink aLk( *this );        // Crsr-Moves ueberwachen, evt. Link callen
aa67036
-    SwCrsrSaveState aSaveState( *pCurCrsr );
aa67036
+    // rhbz#689053: IsSelOvr must restore the saved stack position, not the
aa67036
+    // current one, because current point + stack mark may be invalid PaM
aa67036
+    SwCrsrSaveState aSaveState(*pCrsrStk);
aa67036
     if( pCrsrStk->HasMark() )           // nur wenn GetMark gesetzt wurde
aa67036
     {
aa67036
         bool const bResult =
aa67036
         CheckNodesRange( pCrsrStk->GetMark()->nNode, pCurCrsr->GetPoint()->nNode, sal_True );
aa67036
         OSL_ENSURE(bResult, "StackCrsr & act. Crsr not in same Section.");
aa67036
         (void) bResult; // non-debug: unused
aa67036
-        // kopiere das GetMark
aa67036
-        if( !pCurCrsr->HasMark() )
aa67036
-            pCurCrsr->SetMark();
aa67036
-        *pCurCrsr->GetMark() = *pCrsrStk->GetMark();
aa67036
-        pCurCrsr->GetMkPos() = pCrsrStk->GetMkPos();
aa67036
     }
aa67036
+    *pCrsrStk->GetPoint() = *pCurCrsr->GetPoint();
aa67036
+    pCrsrStk->GetPtPos() = pCurCrsr->GetPtPos();
aa67036
 
aa67036
     SwShellCrsr * pTmp = 0;
aa67036
     if( pCrsrStk->GetNext() != pCrsrStk )
aa67036
     {
aa67036
         pTmp = dynamic_cast<SwShellCrsr*>(pCrsrStk->GetNext());
aa67036
     }
aa67036
-    delete pCrsrStk;
aa67036
+    delete pCurCrsr;
aa67036
+    pCurCrsr = pCrsrStk;
aa67036
+    pCrsrStk->MoveTo(0); // remove from ring
aa67036
     pCrsrStk = pTmp;
aa67036
     if( !pCurCrsr->IsInProtectTable( sal_True ) &&
aa67036
         !pCurCrsr->IsSelOvr( nsSwCursorSelOverFlags::SELOVER_TOGGLE |
aa67036
-- 
aa67036
1.7.11.4
aa67036