VTextDocumentLayout: add debug info for the crash

This commit is contained in:
Le Tan 2018-11-19 19:48:31 +08:00
parent 5b996654cf
commit 31ceeec252

View File

@ -447,14 +447,20 @@ void VTextDocumentLayout::documentChanged(int p_from, int p_charsRemoved, int p_
// TODO: we may need one more next block. // TODO: we may need one more next block.
changeEndBlock = changeStartBlock; changeEndBlock = changeStartBlock;
} else { } else {
changeEndBlock = doc->findBlock(qMax(0, p_from + charsChanged)); changeEndBlock = doc->findBlock(p_from + charsChanged);
} }
qDebug() << "documentChanged" << p_from << p_charsRemoved << p_charsAdded
<< m_blockCount << newBlockCount
<< changeStartBlock.blockNumber() << changeEndBlock.blockNumber();
bool needRelayout = true;
if (changeStartBlock == changeEndBlock if (changeStartBlock == changeEndBlock
&& newBlockCount == m_blockCount) { && newBlockCount == m_blockCount) {
// Change single block internal only. // Change single block internal only.
QTextBlock block = changeStartBlock; QTextBlock block = changeStartBlock;
if (block.isValid() && block.length()) { if (block.isValid() && block.length()) {
needRelayout = false;
QRectF oldBr = blockBoundingRect(block); QRectF oldBr = blockBoundingRect(block);
clearBlockLayout(block); clearBlockLayout(block);
layoutBlockAndUpdateOffset(block); layoutBlockAndUpdateOffset(block);
@ -468,7 +474,9 @@ void VTextDocumentLayout::documentChanged(int p_from, int p_charsRemoved, int p_
return; return;
} }
} }
} else { }
if (needRelayout) {
QTextBlock block = changeStartBlock; QTextBlock block = changeStartBlock;
do { do {
clearBlockLayout(block); clearBlockLayout(block);