mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-09-16 13:36:19 -05:00
Refactor QueueUITask helper
This commit is contained in:
@@ -734,12 +734,10 @@ TempVarSignalManager *TempVarSignalManager::Instance()
|
||||
void NotifyUIAboutTempVarChange(MacroSegment *segment)
|
||||
{
|
||||
IncrementTempVarInUseGeneration();
|
||||
QueueUITask(
|
||||
[](void *segment) {
|
||||
TempVarSignalManager::Instance()->SegmentTempVarsChanged(
|
||||
(MacroSegment *)segment);
|
||||
},
|
||||
segment);
|
||||
QueueUITask([segment]() {
|
||||
TempVarSignalManager::Instance()->SegmentTempVarsChanged(
|
||||
segment);
|
||||
});
|
||||
}
|
||||
|
||||
TempVarOutputMappingsWidget::TempVarOutputMappingsWidget(QWidget *parent)
|
||||
|
||||
@@ -184,9 +184,9 @@ std::string GetThemeTypeName()
|
||||
#endif
|
||||
}
|
||||
|
||||
void QueueUITask(void (*task)(void *param), void *param)
|
||||
void QueueUITaskRaw(void (*task)(void *param), void *param, bool wait)
|
||||
{
|
||||
obs_queue_task(OBS_TASK_UI, task, param, false);
|
||||
obs_queue_task(OBS_TASK_UI, task, param, wait);
|
||||
}
|
||||
|
||||
bool IsCursorInWidgetArea(QWidget *widget)
|
||||
|
||||
@@ -6,7 +6,10 @@
|
||||
#include <QIcon>
|
||||
#include <QString>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
class QAbstractButton;
|
||||
class QComboBox;
|
||||
@@ -38,7 +41,23 @@ EXPORT void DisplayTrayMessage(const QString &title, const QString &msg,
|
||||
EXPORT std::string GetThemeTypeName();
|
||||
EXPORT QWidget *GetSettingsWindow();
|
||||
|
||||
EXPORT void QueueUITask(void (*task)(void *param), void *param);
|
||||
EXPORT void QueueUITaskRaw(void (*task)(void *param), void *param,
|
||||
bool wait = false);
|
||||
|
||||
// Runs func on the main/UI thread; blocks if wait is true.
|
||||
template<typename F> void QueueUITask(F &&func, bool wait = false)
|
||||
{
|
||||
using FnType = std::decay_t<F>;
|
||||
auto *heapFunc = new FnType(std::forward<F>(func));
|
||||
|
||||
QueueUITaskRaw(
|
||||
[](void *param) {
|
||||
std::unique_ptr<FnType> fn(
|
||||
static_cast<FnType *>(param));
|
||||
(*fn)();
|
||||
},
|
||||
heapFunc, wait);
|
||||
}
|
||||
|
||||
bool IsCursorInWidgetArea(QWidget *widget);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user