Add link handler only once for each basic block
authorChristoph Egger <Christoph.Egger@cs.fau.de>
Mon, 23 Feb 2015 15:33:59 +0000 (16:33 +0100)
committerChristoph Egger <Christoph.Egger@cs.fau.de>
Mon, 23 Feb 2015 15:33:59 +0000 (16:33 +0100)
src/gui/widgets/BasicBlockWidget.cxx

index 8e7e440433f6d0948cf7505599517be730bcd03e..0036bda65180ea76cfa8e787332109a597cccfcb 100644 (file)
@@ -69,6 +69,15 @@ BasicBlockWidget::BasicBlockWidget(const QString& name, BasicBlock * block,
                                        Qt::LinksAccessibleByMouse);
 
        if (width < 250) width = 250;
+
+       QObject::connect(_widget.get(), &QGraphicsTextItem::linkActivated,
+                        [=](QString str) {
+                                if (str.startsWith("function:")) {
+                                        QString address = str.remove("function:");
+                                        mainwindow->switchMainPlaneToAddress(address.toInt(NULL, 16));
+                                }
+                        });
+}
 }
 
 void BasicBlockWidget::addItem(uint8_t* bytes, size_t num_bytes,
@@ -102,14 +111,6 @@ void BasicBlockWidget::addItem(uint8_t* bytes, size_t num_bytes,
        }
 
        _table->cellAt(row, 1).firstCursorPosition().insertHtml(line);
-
-       QObject::connect(_widget.get(), &QGraphicsTextItem::linkActivated,
-                        [=](QString str) {
-                                if (str.startsWith("function:")) {
-                                        QString address = str.remove("function:");
-                                        mainwindow->switchMainPlaneToAddress(address.toInt(NULL, 16));
-                                }
-                        });
 }
 
 void BasicBlockWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,