QTextMarkdownImporter: Fix performance for non-trivial documents
While parsing the markdown document, each addition of text and formats was triggering a relayout of the so far existing document, leading to quadratic behavior and very bad performance for any non-trivial markdown document. Guard the changes while parsing with a begin/endEditBlock to avoid these intermediate updates. The performance impact can for example be observed with the markdown editor in Qt Creator (11+). Pick-to: 6.5 Change-Id: I5f89441ea41bc3c6281b616f0c5528b49b48e432 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
parent
e21c4be5d6
commit
9f0b4e18cd
@ -138,7 +138,9 @@ void QTextMarkdownImporter::import(QTextDocument *doc, const QString &markdown)
|
||||
m_monoFont.setPixelSize(doc->defaultFont().pixelSize());
|
||||
qCDebug(lcMD) << "default font" << doc->defaultFont() << "mono font" << m_monoFont;
|
||||
QByteArray md = markdown.toUtf8();
|
||||
m_cursor->beginEditBlock();
|
||||
md_parse(md.constData(), MD_SIZE(md.size()), &callbacks, this);
|
||||
m_cursor->endEditBlock();
|
||||
delete m_cursor;
|
||||
m_cursor = nullptr;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user