cabana: fix hang on scrubbing in zommed chart (#27568)

old-commit-hash: d09a9a08fc21edc03edeb40e1080d8495a7d2915
This commit is contained in:
Dean Lee
2023-03-14 01:25:16 +08:00
committed by GitHub
parent d45e825c56
commit c95ca5a1d5
2 changed files with 11 additions and 7 deletions
+6 -4
View File
@@ -723,10 +723,12 @@ void ChartView::mouseReleaseEvent(QMouseEvent *event) {
void ChartView::mouseMoveEvent(QMouseEvent *ev) {
// Scrubbing
if (is_scrubbing && QApplication::keyboardModifiers().testFlag(Qt::ShiftModifier)) {
double t = chart()->mapToValue({(double)ev->x(), (double)ev->y()}).x();
// Prevent seeking past the end of the route
t = std::clamp(t, 0., can->totalSeconds());
can->seekTo(t);
if (chart()->plotArea().contains(ev->pos())) {
double t = chart()->mapToValue(ev->pos()).x();
// Prevent seeking past the end of the route
t = std::clamp(t, 0., can->totalSeconds());
can->seekTo(t);
}
return;
}
+5 -3
View File
@@ -1,5 +1,5 @@
#include "tools/cabana/streams/abstractstream.h"
#include <QTimer>
#include <QtConcurrent>
AbstractStream *can = nullptr;
@@ -115,6 +115,8 @@ void AbstractStream::updateLastMsgsTo(double sec) {
m.value().freq = m.value().count / std::max(1.0, m.value().ts);
}
}
emit updated();
emit msgsReceived(&can_msgs);
QTimer::singleShot(0, [this]() {
emit updated();
emit msgsReceived(&can_msgs);
});
}