]> git.siccegge.de Git - frida/frida.git/commitdiff
in populateWidget create new TextDocument and attach it at the end
authorChristoph Egger <christoph@christoph-egger.org>
Tue, 26 May 2015 16:04:24 +0000 (18:04 +0200)
committerChristoph Egger <christoph@christoph-egger.org>
Tue, 26 May 2015 16:04:24 +0000 (18:04 +0200)
This is a *huge* performance improvement. Instead of using the
QTextDocument already attached to the QGraphicsTextItem, we create a
new QTextDocument and fill it. Only at the end of populateWidget() we
attach it to the QGraphicsTextItem. This way it will only be layouted
once and not per insert (three times per instruction).

src/gui/widgets/BasicBlockWidget.cxx

index 77a14932999adeedfddc1c77517773909c029bb7..78618c48c6c5ce3ad027b6ec04ef686ead216892 100644 (file)
@@ -219,6 +219,7 @@ void BasicBlockWidget::changeCommentHandler(ChangeCommentEvent* event) {
 void BasicBlockWidget::populateWidget() {
        int row;
        QTextTableFormat format;
+       QTextDocument* document = new QTextDocument();
        format.setBorderStyle(QTextFrameFormat::BorderStyle_None);
        format.setBorder(0);
 
@@ -228,7 +229,7 @@ void BasicBlockWidget::populateWidget() {
                        _table->appendRows(1);
                } else {
                        row = 0;
-                       _table = _widget->textCursor().insertTable(1, 3, format);
+                       _table = QTextCursor(document).insertTable(1, 3, format);
                }
                QString bytestring;
                for (uint8_t byte : inst.getBytes()) {
@@ -259,6 +260,7 @@ void BasicBlockWidget::populateWidget() {
                _table->cellAt(row, 2).firstCursorPosition().insertHtml(formatComments(&inst));
        }
        QGraphicsTextItem* item = _widget.get();
+       item->setDocument(document);
        ((CustomQGraphicsTextItem*)item)->adjustSize();
 }