mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-05 13:26:21 +00:00
Fix FontIterator to not access pos >= par.size()
An iterator is typicall incremented passed the valid data into the 'end'
state. However, if this means that other functions are called with invalid
parameter, we should fix this.
This explains why fontSpan was called with pos==size() while this was not
expected to happen.
This patch reverts partly f5ad0c128a
(Jean-Marc Lasgouttes; Get rid of
annoying warning message).
This commit is contained in:
parent
e115b006e6
commit
88eae06611
@ -1830,13 +1830,7 @@ Font const & Paragraph::getFontSettings(BufferParams const & bparams,
|
||||
|
||||
FontSpan Paragraph::fontSpan(pos_type pos) const
|
||||
{
|
||||
LBUFERR(pos <= size());
|
||||
|
||||
// Last position is a special case. I suspect that it would
|
||||
// actually make sense to extend the last font span to cover
|
||||
// the last character (JMarc)
|
||||
if (pos == size())
|
||||
return FontSpan(pos, pos);
|
||||
LBUFERR(pos < size());
|
||||
|
||||
pos_type start = 0;
|
||||
FontList::const_iterator cit = d->fontlist_.begin();
|
||||
|
@ -771,7 +771,7 @@ public:
|
||||
FontIterator & operator++()
|
||||
{
|
||||
++pos_;
|
||||
if (pos_ > endspan_ || pos_ == bodypos_) {
|
||||
if (pos_ < par_.size() && (pos_ > endspan_ || pos_ == bodypos_)) {
|
||||
font_ = tm_.displayFont(pit_, pos_);
|
||||
endspan_ = par_.fontSpan(pos_).last;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user