From d39f46d62a4c8ae94479101accae21aea5ce6e0e Mon Sep 17 00:00:00 2001 From: Christoph Egger Date: Tue, 26 May 2015 20:38:47 +0200 Subject: [PATCH] Fix redraw bug -- call prepareGeometryChange() "If you want to change the item's bounding rectangle, you must first call prepareGeometryChange()." -- we are now doing so --- src/gui/widgets/BasicBlockWidget.cxx | 10 ++++++++-- src/gui/widgets/BasicBlockWidget.hxx | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/gui/widgets/BasicBlockWidget.cxx b/src/gui/widgets/BasicBlockWidget.cxx index eee78c4..e08cba5 100644 --- a/src/gui/widgets/BasicBlockWidget.cxx +++ b/src/gui/widgets/BasicBlockWidget.cxx @@ -235,6 +235,7 @@ void BasicBlockWidget::populateWidget() { QGraphicsTextItem* item = _widget.get(); item->setDocument(document); item->adjustSize(); + updateSize(); } QString BasicBlockWidget::formatComments(Instruction* inst) { @@ -245,11 +246,16 @@ QString BasicBlockWidget::formatComments(Instruction* inst) { return (comments.empty() ? "" : ";; ") + comments.join("
").trimmed(); } -void BasicBlockWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem*, - QWidget*) { +void BasicBlockWidget::updateSize() { + prepareGeometryChange(); width = 10 + _widget->boundingRect().width(); height = 25 + _widget->boundingRect().height(); if (width < 250) width = 250; +} + +void BasicBlockWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem*, + QWidget*) { + updateSize(); painter->fillRect(0, 0, width, height, currentColor); painter->setPen(QColor(0x00, 0x00, 0xff, 0xff)); diff --git a/src/gui/widgets/BasicBlockWidget.hxx b/src/gui/widgets/BasicBlockWidget.hxx index 7c402c0..ba1153e 100644 --- a/src/gui/widgets/BasicBlockWidget.hxx +++ b/src/gui/widgets/BasicBlockWidget.hxx @@ -60,6 +60,7 @@ private: void populateWidget(); void changeCommentHandler(ChangeCommentEvent* event); QString formatComments(Instruction* inst); + void updateSize(); uint32_t width, height; QString name; -- 2.39.5