From c07ff3589762329226710ff5aa6db01b7cb9b9cc Mon Sep 17 00:00:00 2001 From: oldmud0 Date: Sat, 8 Jan 2022 12:04:57 -0600 Subject: [PATCH 1/3] Fix static effects not appearing Static effects should be treated as infinitely looping animations. --- src/aolayer.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/aolayer.cpp b/src/aolayer.cpp index 08ee392..7c89971 100644 --- a/src/aolayer.cpp +++ b/src/aolayer.cpp @@ -241,6 +241,8 @@ void EffectLayer::load_image(QString p_filename, bool p_looping) play_once = true; continuous = false; force_continuous = true; + cull_image = false; + start_playback(p_filename); // path resolution is handled by the caller for EffectLayer objects play(); } @@ -315,10 +317,10 @@ void AOLayer::start_playback(QString p_image) qDebug() << "[AOLayer::start_playback] Stretch:" << stretch << "Filename:" << p_image; #endif m_reader.setFileName(p_image); - if (m_reader.loopCount() == 0) - play_once = true; last_max_frames = max_frames; max_frames = m_reader.imageCount(); + if (m_reader.loopCount() == 0 && max_frames > 1) + play_once = true; if (!continuous || ((continuous) && (max_frames != last_max_frames)) || max_frames == 0 From 3ec3d3a1217842ef72d8326b6803af70b3f3caa9 Mon Sep 17 00:00:00 2001 From: oldmud0 Date: Sat, 8 Jan 2022 12:51:49 -0600 Subject: [PATCH 2/3] Fix wrong precedence order for effects This was causing the realization.png UI button to be loaded instead of the effect. --- src/text_file_functions.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/text_file_functions.cpp b/src/text_file_functions.cpp index 59b684f..a0caf9b 100644 --- a/src/text_file_functions.cpp +++ b/src/text_file_functions.cpp @@ -875,14 +875,15 @@ QString AOApplication::get_effect(QString effect, QString p_char, if (p_folder == "") p_folder = read_char_ini(p_char, "effects", "Options"); - QString p_path = get_image("effects/" + effect, current_theme, get_subtheme(), default_theme, ""); - QString p_misc_path = get_image(effect, current_theme, get_subtheme(), default_theme, p_folder); + QStringList paths { + get_image("effects/" + effect, current_theme, get_subtheme(), default_theme, ""), + get_image(effect, current_theme, get_subtheme(), default_theme, p_folder) + }; - if (!file_exists(p_misc_path) && !file_exists(p_path)) - return ""; - else if (file_exists(p_misc_path)) - return p_misc_path; - return p_path; + for (const auto &p : paths) + if (file_exists(p)) + return p; + return {}; } QString AOApplication::get_effect_property(QString fx_name, QString p_char, From ba08ec0379fcbe3c62f1d209bd924de129d0f523 Mon Sep 17 00:00:00 2001 From: oldmud0 Date: Sat, 8 Jan 2022 12:55:10 -0600 Subject: [PATCH 3/3] Fix more race conditions in AOLayer loading - Uninitialized exit_loop variable - Previous load task should stop completely before starting new load task --- include/aolayer.h | 2 +- src/aolayer.cpp | 21 +++++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) 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() {