From c6ca25b110ebf83d7981a76a6433a60ee4ae89d0 Mon Sep 17 00:00:00 2001 From: ccolin Date: Tue, 22 Dec 2020 17:57:45 +0100 Subject: [PATCH] fix inconsistencies when loading a file if another is already loaded --- src/drone_controller.cc | 4 ---- src/main_window.cc | 3 +++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/drone_controller.cc b/src/drone_controller.cc index 0a69fd1..406a031 100644 --- a/src/drone_controller.cc +++ b/src/drone_controller.cc @@ -126,7 +126,6 @@ DroneController::DroneController(const QJsonObject &json) } connect(&timer, &QTimer::timeout, this, &DroneController::step); - pause(); } @@ -136,7 +135,6 @@ int DroneController::getDuration() const { void DroneController::step() { - // qDebug("frame %d (%d%%)", frame, (int) ((double) frame / duration * 100)); for (Drone d : drones) { d.setTo(frame); } @@ -154,7 +152,6 @@ void DroneController::play() { if (!paused) return; paused = false; timer.start(1000. / framerate); - qDebug() << "playing"; emit playing(); } @@ -163,7 +160,6 @@ void DroneController::pause() { if (paused) return; paused = true; timer.stop(); - qDebug() << "pausing"; emit pausing(); } diff --git a/src/main_window.cc b/src/main_window.cc index 8acfefb..7bc7855 100644 --- a/src/main_window.cc +++ b/src/main_window.cc @@ -53,16 +53,19 @@ void MainWindow::open(const QString &path) { QByteArray data = file.readAll(); QJsonDocument json_doc = QJsonDocument::fromJson(data); if (dc) delete dc; + glw.meshes.clear(); dc = new DroneController(json_doc.object()); playpause_action->setEnabled(true); connect(dc, &DroneController::playing, this, &MainWindow::play); connect(dc, &DroneController::pausing, this, &MainWindow::pause); slider->setMinimum(0); slider->setMaximum(dc->getDuration()); + slider->setValue(0); connect(slider, &QSlider::sliderPressed, dc, &DroneController::suspend); connect(slider, &QSlider::sliderReleased, dc, &DroneController::resume); connect(slider, &QSlider::valueChanged, dc, &DroneController::seek); connect(dc, &DroneController::frameChanged, slider, &QSlider::setValue); + pause(); slider->setEnabled(true); }