From fc39f11e52ae7b3fa3073aab38fdd4eecbdc02d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Mon, 5 Feb 2018 12:04:34 +0100 Subject: Fix widget docking for MemoryView For some reason the layout resize resulted to different height then we counted out. So just calculate it on place instead. --- qtmips_gui/memoryview.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/qtmips_gui/memoryview.cpp b/qtmips_gui/memoryview.cpp index cd01d4a..beb364d 100644 --- a/qtmips_gui/memoryview.cpp +++ b/qtmips_gui/memoryview.cpp @@ -154,16 +154,17 @@ void MemoryView::Frame::check_update() { int hpart = qMax(height()/10, MIN_OFF); int req_height = height() + 2*hpart; - while (!((content_y <= -hpart) && (content_y >= -2*hpart)) || (widg->height() <= req_height)) { - int row_h = widg->row_size(); - // Calculate how many we need and how much we need to move and update content accordingly - int count = (req_height / row_h) + 1; - int shift = (content_y + hpart + hpart/2)/row_h; - mv->update_content(count * widg->columns(), shift * widg->columns()); - // Move and resize widget - content_y -= shift * row_h; - widg->setGeometry(0, content_y, width(), widg->heightForWidth(width())); - } + if (((content_y > -hpart) || (content_y < -2*hpart)) && (widg->height() >= req_height)) + return; + + int row_h = widg->row_size(); + // Calculate how many we need and how much we need to move and update content accordingly + int count = (req_height / row_h) + 1; + int shift = (content_y + hpart + hpart/2)/row_h; + mv->update_content(count * widg->columns(), shift * widg->columns()); + // Move and resize widget + content_y -= shift * row_h; + widg->setGeometry(0, content_y, width(), count * row_h); mv->edit_load_focus(); } @@ -172,7 +173,6 @@ void MemoryView::Frame::resizeEvent(QResizeEvent *e) { QAbstractScrollArea::resizeEvent(e); widg->setGeometry(0, content_y, e->size().width(), widg->heightForWidth(e->size().width())); check_update(); - } void MemoryView::Frame::wheelEvent(QWheelEvent *e) { -- cgit v1.2.3