mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
bug-fix: findFirstVisibleBlock() return invalid block when fails
A huge block as the last block may lead to failure to find first visible block.
This commit is contained in:
parent
2b78711eb4
commit
26d14f81d5
@ -1021,6 +1021,10 @@ void VEdit::lineNumberAreaPaintEvent(QPaintEvent *p_event)
|
||||
QAbstractTextDocumentLayout *layout = document()->documentLayout();
|
||||
|
||||
QTextBlock block = firstVisibleBlock();
|
||||
if (!block.isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int blockNumber = block.blockNumber();
|
||||
int offsetY = contentOffsetY();
|
||||
QRectF rect = layout->blockBoundingRect(block);
|
||||
@ -1196,8 +1200,7 @@ QTextBlock VEdit::firstVisibleBlock()
|
||||
block = block.next();
|
||||
}
|
||||
|
||||
Q_ASSERT(false);
|
||||
return doc->begin();
|
||||
return QTextBlock();
|
||||
}
|
||||
|
||||
int LineNumberArea::calculateWidth() const
|
||||
|
Loading…
x
Reference in New Issue
Block a user