diff --git a/lib/queue/action-queue.cpp b/lib/queue/action-queue.cpp index 6eaa9be1..9ee4576b 100644 --- a/lib/queue/action-queue.cpp +++ b/lib/queue/action-queue.cpp @@ -1,6 +1,7 @@ #include "action-queue.hpp" #include "obs-module-helper.hpp" #include "plugin-state-helpers.hpp" +#include "ui-helpers.hpp" namespace advss { @@ -379,11 +380,24 @@ static bool queueWithNameExists(const std::string &name) return !GetWeakActionQueueByName(name).expired(); } +static void signalImportedQueues(void *varsPtr) +{ + auto queues = std::unique_ptr>>( + static_cast> *>(varsPtr)); + for (const auto &queue : *queues) { + ActionQueueSignalManager::Instance()->Add( + QString::fromStdString(queue->Name())); + } +} + void ImportQueues(obs_data_t *data) { OBSDataArrayAutoRelease array = obs_data_get_array(data, "actionQueues"); size_t count = obs_data_array_count(array); + + auto importedQueues = new std::vector>; + for (size_t i = 0; i < count; i++) { OBSDataAutoRelease arrayElement = obs_data_array_item(array, i); auto queue = ActionQueue::Create(); @@ -392,7 +406,10 @@ void ImportQueues(obs_data_t *data) continue; } queues.emplace_back(queue); + importedQueues->emplace_back(queue); } + + QeueUITask(signalImportedQueues, importedQueues); } std::weak_ptr GetWeakActionQueueByName(const std::string &name) diff --git a/lib/utils/ui-helpers.cpp b/lib/utils/ui-helpers.cpp index dd5f6ed2..ab2b2469 100644 --- a/lib/utils/ui-helpers.cpp +++ b/lib/utils/ui-helpers.cpp @@ -166,4 +166,9 @@ std::string GetThemeTypeName() #endif } +void QeueUITask(void (*task)(void *param), void *param) +{ + obs_queue_task(OBS_TASK_UI, task, param, false); +} + } // namespace advss diff --git a/lib/utils/ui-helpers.hpp b/lib/utils/ui-helpers.hpp index 41407373..bfd0607e 100644 --- a/lib/utils/ui-helpers.hpp +++ b/lib/utils/ui-helpers.hpp @@ -29,4 +29,6 @@ EXPORT void DisplayTrayMessage(const QString &title, const QString &msg, EXPORT std::string GetThemeTypeName(); +void QeueUITask(void (*task)(void *param), void *param); + } // namespace advss diff --git a/lib/variables/variable.cpp b/lib/variables/variable.cpp index db9dbb30..d6c43e3c 100644 --- a/lib/variables/variable.cpp +++ b/lib/variables/variable.cpp @@ -1,6 +1,7 @@ #include "variable.hpp" #include "math-helpers.hpp" #include "obs-module-helper.hpp" +#include "ui-helpers.hpp" #include "utility.hpp" #include @@ -375,11 +376,23 @@ void LoadVariables(obs_data_t *obj) obs_data_array_release(variablesArray); } +static void signalImportedVariables(void *varsPtr) +{ + auto vars = std::unique_ptr>>( + static_cast> *>(varsPtr)); + for (const auto &var : *vars) { + VariableSignalManager::Instance()->Add( + QString::fromStdString(var->Name())); + } +} + void ImportVariables(obs_data_t *data) { obs_data_array_t *array = obs_data_get_array(data, "variables"); size_t count = obs_data_array_count(array); + auto importedVars = new std::vector>; + for (size_t i = 0; i < count; i++) { obs_data_t *arrayElement = obs_data_array_item(array, i); auto var = Variable::Create(); @@ -391,9 +404,12 @@ void ImportVariables(obs_data_t *data) } GetVariables().emplace_back(var); + importedVars->emplace_back(var); } obs_data_array_release(array); + + QeueUITask(signalImportedVariables, importedVars); } std::chrono::high_resolution_clock::time_point GetLastVariableChangeTime() diff --git a/tests/mocks/ui-helpers.cpp b/tests/mocks/ui-helpers.cpp index 3cd23767..8dd3ac85 100644 --- a/tests/mocks/ui-helpers.cpp +++ b/tests/mocks/ui-helpers.cpp @@ -33,4 +33,6 @@ std::string GetThemeTypeName() return "Dark"; } +void QeueUITask(void (*task)(void *param), void *) {} + } // namespace advss