]> git.siccegge.de Git - frida/frida.git/blobdiff - src/gui/widgets/BasicBlockWidget.cxx
in populateWidget create new TextDocument and attach it at the end
[frida/frida.git] / src / gui / widgets / BasicBlockWidget.cxx
index 1cdc33f3dc7eb2ce4cf67f84ba8b1e77a0f24d0d..78618c48c6c5ce3ad027b6ec04ef686ead216892 100644 (file)
@@ -117,7 +117,8 @@ BasicBlockWidget::BasicBlockWidget(const QString& name, BasicBlock * block,
        , logger(log4cxx::Logger::getLogger("gui.BasicBlockWidget." + name.toStdString())) {
        next[0] = NULL; next[1] = NULL;
 
-       block->getManager()->registerRenameFunctionEvent([=](RenameFunctionEvent* event) {updateFunctionName(event);});
+       QObject::connect(block->getManager(), &InformationManager::renameFunctionEvent,
+                        [=](RenameFunctionEvent* event) {updateFunctionName(event);});
 
        _widget.reset(new CustomQGraphicsTextItem("", this));
        _widget->setPos(5, 20);
@@ -150,7 +151,8 @@ BasicBlockWidget::BasicBlockWidget(const QString& name, BasicBlock * block,
                         });
        instructions = block->getInstructions();
        populateWidget();
-       block->getManager()->registerChangeCommentEvent([=](ChangeCommentEvent* e) {changeCommentHandler(e);});
+       QObject::connect(block->getManager(), &InformationManager::changeCommentEvent,
+                        [=](ChangeCommentEvent* e) {changeCommentHandler(e);});
 }
 
 void BasicBlockWidget::updateFunctionName(RenameFunctionEvent *event) {
@@ -217,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);
 
@@ -226,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()) {
@@ -257,16 +260,16 @@ void BasicBlockWidget::populateWidget() {
                _table->cellAt(row, 2).firstCursorPosition().insertHtml(formatComments(&inst));
        }
        QGraphicsTextItem* item = _widget.get();
+       item->setDocument(document);
        ((CustomQGraphicsTextItem*)item)->adjustSize();
 }
 
 QString BasicBlockWidget::formatComments(Instruction* inst) {
-       QString comments;
+       QStringList comments;
        for (Comment* c: inst->comments()) {
-               comments += "<br />";
-               comments += QString(c->getText().c_str()).toHtmlEscaped();
+               comments << QString(c->getText().c_str()).toHtmlEscaped();
        }
-       return (comments == "" ? "" : ";; ") + comments.trimmed();
+       return (comments.empty() ? "" : ";; ") + comments.join("<br />").trimmed();
 }
 
 void BasicBlockWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem*,