From 8ad70251e6eca8c236a75b6f8b924f9d808388cd Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Wed, 18 May 2022 09:23:16 +0800 Subject: [PATCH] fix: trigger pannel resize to max, DSView crashed --- DSView/pv/mainframe.cpp | 22 +++++++++++----------- DSView/pv/view/dsosignal.cpp | 5 +++-- DSView/pv/widgets/decodergroupbox.cpp | 14 ++------------ 3 files changed, 16 insertions(+), 25 deletions(-) diff --git a/DSView/pv/mainframe.cpp b/DSView/pv/mainframe.cpp index 29c420e9..0977b432 100644 --- a/DSView/pv/mainframe.cpp +++ b/DSView/pv/mainframe.cpp @@ -42,8 +42,8 @@ #include #include #include -#include -#include +#include +#include #include "dsvdef.h" #include "config/appconfig.h" @@ -421,19 +421,21 @@ void MainFrame::readSettings() int right = app._frameOptions.right; int bottom = app._frameOptions.bottom; - QRect scRect = QApplication::desktop()->screenGeometry(); + int screen_width = QGuiApplication::primaryScreen()->availableGeometry().width(); + int screen_height = QGuiApplication::primaryScreen()->availableGeometry().height(); + bool bReset = false; if (right == 0) { bReset = true; } - if (right - left >= scRect.width()) + if (right - left >= screen_width) { bReset = true; } int sp = 70; - if (right < sp || bottom < sp || left + sp >= scRect.width() || top + sp >= scRect.height()){ + if (right < sp || bottom < sp || left + sp >= screen_width || top + sp >= screen_height){ bReset = true; } @@ -442,12 +444,10 @@ void MainFrame::readSettings() showMaximized(); // show max by system api } else if (bReset) - { - QScreen *screen = QGuiApplication::primaryScreen(); - const QRect availableGeometry = screen->availableGeometry(); - resize(availableGeometry.width() / 2, availableGeometry.height() / 1.5); - const int origX = std::max(0, (availableGeometry.width() - width()) / 2); - const int origY = std::max(0, (availableGeometry.height() - height()) / 2); + { + resize(screen_width / 2, screen_height / 1.5); + const int origX = std::max(0, (screen_width - width()) / 2); + const int origY = std::max(0, (screen_height - height()) / 2); move(origX, origY); } else diff --git a/DSView/pv/view/dsosignal.cpp b/DSView/pv/view/dsosignal.cpp index c3847f51..bd8e8114 100755 --- a/DSView/pv/view/dsosignal.cpp +++ b/DSView/pv/view/dsosignal.cpp @@ -826,12 +826,13 @@ void DsoSignal::paint_mid(QPainter &p, int left, int right, QColor fore, QColor (void)fore; (void)back; - if (!_show) + if (!_show || right >= left){ return; + } assert(_data); assert(_view); - assert(right >= left); + //assert(right >= left); if (enabled()) { const int index = get_index(); diff --git a/DSView/pv/widgets/decodergroupbox.cpp b/DSView/pv/widgets/decodergroupbox.cpp index 2d402bbb..20fa6f22 100755 --- a/DSView/pv/widgets/decodergroupbox.cpp +++ b/DSView/pv/widgets/decodergroupbox.cpp @@ -113,8 +113,7 @@ DecoderGroupBox::DecoderGroupBox(data::DecoderStack *decoder_stack, _widget->setLayout(_layout); parent->layout()->addWidget(_widget); - // setWidget(_widget); - // _widget->installEventFilter(this); + } DecoderGroupBox::~DecoderGroupBox() @@ -122,16 +121,7 @@ DecoderGroupBox::~DecoderGroupBox() } bool DecoderGroupBox::eventFilter(QObject *o, QEvent *e) -{ - /* - if(o == _widget && e->type() == QEvent::Resize) { - setMinimumWidth(_widget->minimumSizeHint().width() + verticalScrollBar()->width()); - QScreen *screen=QGuiApplication::primaryScreen (); - QRect mm=screen->availableGeometry() ; - if (_widget->minimumSizeHint().height() < mm.height()/2) - setMinimumHeight(_widget->minimumSizeHint().height()); - } - */ +{ return false; }