Permalink
Browse files

Better fix for export infinite loop

  • Loading branch information...
1 parent d6d9b73 commit 6e8305120425d913f3f8bf31cbb7493bce892e9b Eoin Mcloughlin committed Oct 31, 2016
Showing with 9 additions and 3 deletions.
  1. +8 −3 plotview.cpp
  2. +1 −0 plotview.h
View
@@ -113,8 +113,9 @@ void PlotView::contextMenuEvent(QContextMenuEvent * event)
save->setEnabled(src->sampleType() == typeid(std::complex<float>));
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()));
View
@@ -82,6 +82,7 @@ public slots:
void exportSamples(std::shared_ptr<AbstractSampleSource> src);
int plotsHeight();
off_t samplesPerLine();
+ void updateViewRange(bool reCenter);
void updateView(bool reCenter = false);
void paintTimeScale(QPainter &painter, QRect &rect, range_t<off_t> sampleRange);
};

0 comments on commit 6e83051

Please sign in to comment.