mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-10-04 15:47:53 -05:00
Refactor QueueUITask helper
This commit is contained in:
@@ -17,20 +17,6 @@ bool MacroActionSceneCollection::_registered = MacroActionFactory::Register(
|
||||
MacroActionSceneCollectionEdit::Create,
|
||||
"AdvSceneSwitcher.action.sceneCollection"});
|
||||
|
||||
template<typename F> void QueueUITaskLambda(F &&func)
|
||||
{
|
||||
using FnType = std::decay_t<F>;
|
||||
auto *heapFunc = new FnType(std::forward<F>(func));
|
||||
|
||||
QueueUITask(
|
||||
[](void *param) {
|
||||
std::unique_ptr<FnType> fn(
|
||||
static_cast<FnType *>(param));
|
||||
(*fn)();
|
||||
},
|
||||
heapFunc);
|
||||
}
|
||||
|
||||
bool MacroActionSceneCollection::PerformAction()
|
||||
{
|
||||
// Changing the scene collection will also reload the settings of the
|
||||
@@ -41,7 +27,7 @@ bool MacroActionSceneCollection::PerformAction()
|
||||
}
|
||||
|
||||
const auto collectionName = _sceneCollection;
|
||||
QueueUITaskLambda([collectionName]() {
|
||||
QueueUITask([collectionName]() {
|
||||
obs_frontend_set_current_scene_collection(
|
||||
collectionName.c_str());
|
||||
});
|
||||
|
||||
@@ -185,20 +185,6 @@ static void closeSourceDialog(obs_source_t *source, bool accept,
|
||||
}
|
||||
}
|
||||
|
||||
template<typename F> void QueueUITaskLambda(F &&func)
|
||||
{
|
||||
using FnType = std::decay_t<F>;
|
||||
auto *heapFunc = new FnType(std::forward<F>(func));
|
||||
|
||||
QueueUITask(
|
||||
[](void *param) {
|
||||
std::unique_ptr<FnType> fn(
|
||||
static_cast<FnType *>(param));
|
||||
(*fn)();
|
||||
},
|
||||
heapFunc);
|
||||
}
|
||||
|
||||
bool MacroActionSource::PerformAction()
|
||||
{
|
||||
OBSSource s = obs_weak_source_get_source(_source.GetSource());
|
||||
@@ -271,17 +257,17 @@ bool MacroActionSource::PerformAction()
|
||||
break;
|
||||
}
|
||||
|
||||
QueueUITaskLambda([&]() {
|
||||
QueueUITask([&]() {
|
||||
closeSourceDialog(s, true, "OBSBasicInteraction");
|
||||
});
|
||||
break;
|
||||
case Action::CLOSE_FILTER_DIALOG:
|
||||
QueueUITaskLambda([&]() {
|
||||
QueueUITask([&]() {
|
||||
closeSourceDialog(s, _acceptDialog, "OBSBasicFilters");
|
||||
});
|
||||
break;
|
||||
case Action::CLOSE_PROPERTIES_DIALOG:
|
||||
QueueUITaskLambda([&]() {
|
||||
QueueUITask([&]() {
|
||||
closeSourceDialog(s, _acceptDialog,
|
||||
"OBSBasicProperties");
|
||||
});
|
||||
|
||||
@@ -31,14 +31,9 @@ static bool setup()
|
||||
static const auto showInvalidWarnings = [](void *) {
|
||||
const auto invalidTokens = getInvalidTokens();
|
||||
for (const auto &token : invalidTokens) {
|
||||
QueueUITask(
|
||||
[](void *tokenPtr) {
|
||||
auto tokenName = static_cast<QString *>(
|
||||
tokenPtr);
|
||||
InvalidTokenDialog::ShowWarning(
|
||||
*tokenName);
|
||||
},
|
||||
(void *)&token);
|
||||
QueueUITask([token]() {
|
||||
InvalidTokenDialog::ShowWarning(token);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user