From 6e8305120425d913f3f8bf31cbb7493bce892e9b Mon Sep 17 00:00:00 2001 From: Eoin Mcloughlin Date: Mon, 31 Oct 2016 18:09:59 +0000 Subject: [PATCH] Better fix for export infinite loop --- plotview.cpp | 11 ++++++++--- plotview.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/plotview.cpp b/plotview.cpp index 52c1865..727f932 100644 --- a/plotview.cpp +++ b/plotview.cpp @@ -113,8 +113,9 @@ void PlotView::contextMenuEvent(QContextMenuEvent * event) save->setEnabled(src->sampleType() == typeid(std::complex)); menu.addAction(save); - updateView(false); - menu.exec(event->globalPos()); + updateViewRange(false); + if(menu.exec(event->globalPos())) + updateView(false); } void PlotView::cursorsMoved() @@ -459,7 +460,7 @@ void PlotView::scrollContentsBy(int dx, int dy) updateView(); } -void PlotView::updateView(bool reCenter) +void PlotView::updateViewRange(bool reCenter) { // Store old view for recentering auto oldViewRange = viewRange; @@ -476,7 +477,11 @@ void PlotView::updateView(bool reCenter) horizontalScrollBar()->value() + (oldViewRange.length() - viewRange.length()) / 2 ); } +} +void PlotView::updateView(bool reCenter) +{ + updateViewRange(reCenter); horizontalScrollBar()->setMaximum(std::max(off_t(0), mainSampleSource->count() - ((width() - 1) * samplesPerLine()))); verticalScrollBar()->setMaximum(std::max(0, plotsHeight() - viewport()->height())); diff --git a/plotview.h b/plotview.h index 322c581..5a76612 100644 --- a/plotview.h +++ b/plotview.h @@ -82,6 +82,7 @@ private: void exportSamples(std::shared_ptr src); int plotsHeight(); off_t samplesPerLine(); + void updateViewRange(bool reCenter); void updateView(bool reCenter = false); void paintTimeScale(QPainter &painter, QRect &rect, range_t sampleRange); };