Hi Cedric,
Thanks a lot for your reviewing.
I am very happy to hear the opinions of the expert.
(11/11/15 18:30), Cedric Bosdonnat wrote:
* The if should be like the following or we still have the crash when
the last line is removed.
if( pSavePos&& pSavePos->nNode< uNodeCount )
I was wrong.
Thanks for pointing out.
I attached a revised patch.
* Then I have no idea why you added the checks on the nIdx, I have the
impression that this is not really needed.
The verificationwill avoid the strange behavior such as the
following(not a crash).
Steps to reproduce:
1. Create a new document
2. Type AAA
3. Edit > Find & replace
4. Find : A+
5. Replace with nothing
6. Check « Regular expressions »
7. Click “Replace all''
8. Close dialog.
9. Type B
10. Type Backspace key.
11. B is not deleted.
I think thatthis strange behavior should be corrected in the
"SwCursor::RestoreSavePos()" method,
and "SwCursor::RestoreSavePos()" method should note both
"pSavePos->nNode" and "pSavePos->nCntnt" value.
So I added the verification.
But, perhaps, the verificationmay not be included in the same commit to
fix fdo#40831.
I noticed in your point,and I'm still wondering.
Please tell me your opinion again,If you think that you need.
Best regards,
--
Tomofumi Yagi
diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx
index c27d8f7..fd6c782 100644
--- a/sw/source/core/crsr/swcrsr.cxx
+++ b/sw/source/core/crsr/swcrsr.cxx
@@ -2091,10 +2091,22 @@ sal_Bool SwCursor::MoveSection( SwWhichSection
fnWhichSect,
void SwCursor::RestoreSavePos()
{
- if( pSavePos )
+ // fdo#40831 if you delete the row or column containing pSavePos,
+ // Writer will crash. Work around this.
+ sal_uLong uNodeCount = GetPoint()->nNode.GetNodes().Count();
+ if( pSavePos && pSavePos->nNode < uNodeCount )
{
GetPoint()->nNode = pSavePos->nNode;
- GetPoint()->nContent.Assign( GetCntntNode(), pSavePos->nCntnt );
+
+ xub_StrLen nIdx = 0;
+ if ( GetCntntNode() )
+ if ( pSavePos->nCntnt <= GetCntntNode()->Len() )
+ nIdx = pSavePos->nCntnt;
+ else
+ nIdx = GetCntntNode()->Len();
+ else
+ nIdx = GetPoint()->nContent.GetIndex(); // Probably, nIdx = 0
+ GetPoint()->nContent.Assign( GetCntntNode(), nIdx );
}
}
_______________________________________________
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice