diff --git a/include/aolayer.h b/include/aolayer.h index 4d2629b..830dd69 100644 --- a/include/aolayer.h +++ b/include/aolayer.h @@ -148,7 +148,7 @@ private: // used in populate_vectors void load_next_frame(); - std::atomic_bool exit_loop; //awful solution but i'm not fucking using QThread + std::atomic_bool exit_loop = false; //awful solution but i'm not fucking using QThread QFuture frame_loader; QMutex mutex; QWaitCondition frameAdded; diff --git a/src/aolayer.cpp b/src/aolayer.cpp index 7c89971..a5e1d9b 100644 --- a/src/aolayer.cpp +++ b/src/aolayer.cpp @@ -284,9 +284,11 @@ void AOLayer::start_playback(QString p_image) this->kill(); return; } - QMutexLocker locker(&mutex); + if (frame_loader.isRunning()) exit_loop = true; // tell the loader to stop, we have a new image to load + + QMutexLocker locker(&mutex); this->show(); if (!ao_app->is_continuous_enabled()) { @@ -561,13 +563,20 @@ void AOLayer::movie_ticker() } void AOLayer::populate_vectors() { - while (!exit_loop && movie_frames.size() < max_frames) { - load_next_frame(); #ifdef DEBUG_MOVIE - qDebug() << "[AOLayer::populate_vectors] Loaded frame" << movie_frames.size(); + qDebug() << "[AOLayer::populate_vectors] Started thread"; #endif - } - exit_loop = false; + while (!exit_loop && movie_frames.size() < max_frames) { + load_next_frame(); +#ifdef DEBUG_MOVIE + qDebug() << "[AOLayer::populate_vectors] Loaded frame" << movie_frames.size(); +#endif + } +#ifdef DEBUG_MOVIE + if (exit_loop) + qDebug() << "[AOLayer::populate_vectors] Exit requested"; +#endif + exit_loop = false; } void AOLayer::load_next_frame() {