summaryrefslogtreecommitdiffstats
path: root/editeng
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2012-02-03 14:19:47 +0100
committerMichael Stahl <mstahl@redhat.com>2012-02-03 14:20:13 +0100
commit874f2e53b24ad24d4e99f0df54ba6539d1958371 (patch)
tree923251de8906b3f3f7877b08d2e80c2e6a3b1784 /editeng
parentediteng: convert some DBG_ASSERTs (diff)
downloadcore-874f2e53b24ad24d4e99f0df54ba6539d1958371.tar.gz
core-874f2e53b24ad24d4e99f0df54ba6539d1958371.zip
WrongList::TextInserted: fix STL crash
vector iterators and insert don't mix well (regression from dfbf0cabfa8310502e19642d56c746cc0d454d27)
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/editeng/edtspell.cxx37
1 files changed, 20 insertions, 17 deletions
diff --git a/editeng/source/editeng/edtspell.cxx b/editeng/source/editeng/edtspell.cxx
index f13fb1a729f4..eda0d6143d5a 100644
--- a/editeng/source/editeng/edtspell.cxx
+++ b/editeng/source/editeng/edtspell.cxx
@@ -242,48 +242,51 @@ void WrongList::TextInserted( sal_uInt16 nPos, sal_uInt16 nNew, sal_Bool bPosIsS
nInvalidEnd = nPos+nNew;
}
- for (WrongList::iterator i = begin(); i != end(); ++i)
+ for (WrongList::size_type i = 0; i < size(); ++i)
{
+ WrongRange & rWrong = (*this)[i]; // why does this thing derive vector?
sal_Bool bRefIsValid = sal_True;
- if (i->nEnd >= nPos)
+ if (rWrong.nEnd >= nPos)
{
// Move all Wrongs after the insert position...
- if (i->nStart > nPos)
+ if (rWrong.nStart > nPos)
{
- i->nStart += nNew;
- i->nEnd += nNew;
+ rWrong.nStart += nNew;
+ rWrong.nEnd += nNew;
}
// 1: Starts before and goes until nPos...
- else if (i->nEnd == nPos)
+ else if (rWrong.nEnd == nPos)
{
// Should be halted at a blank!
if ( !bPosIsSep )
- i->nEnd += nNew;
+ rWrong.nEnd += nNew;
}
// 2: Starts before and goes until after nPos...
- else if (i->nStart < nPos && i->nEnd > nPos)
+ else if ((rWrong.nStart < nPos) && (rWrong.nEnd > nPos))
{
- i->nEnd += nNew;
+ rWrong.nEnd += nNew;
// When a separator remove and re-examine the Wrong
if ( bPosIsSep )
{
// Split Wrong...
- WrongRange aNewWrong(i->nStart, nPos);
- i->nStart = nPos + 1;
- insert(i, aNewWrong);
- bRefIsValid = sal_False; // Reference no longer valid after Insert, the other was inserted in front of this position
+ WrongRange aNewWrong(rWrong.nStart, nPos);
+ rWrong.nStart = nPos + 1;
+ insert(begin() + i, aNewWrong);
+ // Reference no longer valid after Insert, the other
+ // was inserted in front of this position
+ bRefIsValid = false;
++i; // Not this again...
}
}
// 3: Attribute starts at position ..
- else if (i->nStart == nPos)
+ else if (rWrong.nStart == nPos)
{
- i->nEnd += nNew;
+ rWrong.nEnd += nNew;
if ( bPosIsSep )
- ++(i->nStart);
+ ++(rWrong.nStart);
}
}
- SAL_WARN_IF(bRefIsValid && i->nStart >= i->nEnd, "editeng",
+ SAL_WARN_IF(bRefIsValid && rWrong.nStart >= rWrong.nEnd, "editeng",
"TextInserted, WrongRange: Start >= End?!");
(void)bRefIsValid;
}