mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-28 04:06:27 -05:00
Fix plugin state condition not functioning on OBS shutdown
Also added note indicating the limitations of running macros on OBS shutdown
This commit is contained in:
@@ -299,6 +299,7 @@ AdvSceneSwitcher.condition.pluginState.state.start="Plugin started"
|
||||
AdvSceneSwitcher.condition.pluginState.state.restart="Plugin restarted"
|
||||
AdvSceneSwitcher.condition.pluginState.state.running="Plugin is running"
|
||||
AdvSceneSwitcher.condition.pluginState.state.shutdown="OBS is shutting down"
|
||||
AdvSceneSwitcher.condition.pluginState.state.shutdown.limitation="Note that while actions performing OBS specific changes will still be executed on shutdown those changes will not be saved as OBS is already shutting down!"
|
||||
AdvSceneSwitcher.condition.pluginState.state.sceneCollection="Scene collection loaded"
|
||||
AdvSceneSwitcher.condition.pluginState.state.sceneSwitched="Scene changed by previous macro"
|
||||
AdvSceneSwitcher.condition.pluginState.entry="{{condition}}"
|
||||
|
||||
@@ -123,6 +123,10 @@ static void AskForBackup(obs_data_t *obj);
|
||||
|
||||
static void SaveSceneSwitcher(obs_data_t *save_data, bool saving, void *)
|
||||
{
|
||||
if (!switcher) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (saving) {
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->Prune();
|
||||
@@ -614,7 +618,7 @@ static void setStreamStopping()
|
||||
std::chrono::high_resolution_clock::now();
|
||||
}
|
||||
|
||||
static void handleExit()
|
||||
static void handleShutdown()
|
||||
{
|
||||
if (!switcher) {
|
||||
return;
|
||||
@@ -624,8 +628,14 @@ static void handleExit()
|
||||
switcher->Stop();
|
||||
switcher->CheckMacros();
|
||||
switcher->RunMacros();
|
||||
|
||||
// Unfortunately this will not work as OBS will now allow saving
|
||||
// the scene collection data at this point, So any OBS specific
|
||||
// changes done during shutdown will be lost
|
||||
//
|
||||
// TODO: Look for a way to possibly resolve this
|
||||
obs_frontend_save();
|
||||
}
|
||||
FreeSceneSwitcher();
|
||||
}
|
||||
|
||||
static void handleSceneCollectionChanging()
|
||||
@@ -649,8 +659,12 @@ static void OBSEvent(enum obs_frontend_event event, void *switcher)
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
case OBS_FRONTEND_EVENT_EXIT:
|
||||
handleExit();
|
||||
case OBS_FRONTEND_EVENT_SCRIPTING_SHUTDOWN:
|
||||
// Note: We are intentionally not listening for
|
||||
// OBS_FRONTEND_EVENT_EXIT here as at that point all scene
|
||||
// collection data will already have been cleared and thus all
|
||||
// macros will have already been cleared
|
||||
handleShutdown();
|
||||
break;
|
||||
case OBS_FRONTEND_EVENT_SCENE_CHANGED:
|
||||
handleSceneChange();
|
||||
|
||||
@@ -112,24 +112,28 @@ static inline void populateConditionSelection(QComboBox *list)
|
||||
|
||||
MacroConditionPluginStateEdit::MacroConditionPluginStateEdit(
|
||||
QWidget *parent, std::shared_ptr<MacroConditionPluginState> entryData)
|
||||
: QWidget(parent)
|
||||
: QWidget(parent),
|
||||
_condition(new QComboBox()),
|
||||
_shutdownLimitation(new QLabel(obs_module_text(
|
||||
"AdvSceneSwitcher.condition.pluginState.state.shutdown.limitation")))
|
||||
{
|
||||
_condition = new QComboBox();
|
||||
|
||||
_shutdownLimitation->setWordWrap(true);
|
||||
QWidget::connect(_condition, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(ConditionChanged(int)));
|
||||
populateConditionSelection(_condition);
|
||||
|
||||
QHBoxLayout *switchLayout = new QHBoxLayout;
|
||||
auto entryLayout = new QHBoxLayout;
|
||||
std::unordered_map<std::string, QWidget *> widgetPlaceholders = {
|
||||
{"{{condition}}", _condition},
|
||||
};
|
||||
PlaceWidgets(
|
||||
obs_module_text("AdvSceneSwitcher.condition.pluginState.entry"),
|
||||
switchLayout, widgetPlaceholders);
|
||||
entryLayout, widgetPlaceholders);
|
||||
entryLayout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addLayout(switchLayout);
|
||||
auto mainLayout = new QVBoxLayout;
|
||||
mainLayout->addLayout(entryLayout);
|
||||
mainLayout->addWidget(_shutdownLimitation);
|
||||
setLayout(mainLayout);
|
||||
|
||||
_entryData = entryData;
|
||||
@@ -155,6 +159,7 @@ void MacroConditionPluginStateEdit::ConditionChanged(int idx)
|
||||
MacroConditionPluginState::Condition::OBS_SHUTDOWN) {
|
||||
switcher->shutdownConditionCount++;
|
||||
}
|
||||
SetWidgetVisibility();
|
||||
}
|
||||
|
||||
void MacroConditionPluginStateEdit::UpdateEntryData()
|
||||
@@ -165,6 +170,16 @@ void MacroConditionPluginStateEdit::UpdateEntryData()
|
||||
|
||||
_condition->setCurrentIndex(
|
||||
_condition->findData(static_cast<int>(_entryData->_condition)));
|
||||
SetWidgetVisibility();
|
||||
}
|
||||
|
||||
void MacroConditionPluginStateEdit::SetWidgetVisibility()
|
||||
{
|
||||
_shutdownLimitation->setVisible(
|
||||
_entryData->_condition ==
|
||||
MacroConditionPluginState::Condition::OBS_SHUTDOWN);
|
||||
adjustSize();
|
||||
updateGeometry();
|
||||
}
|
||||
|
||||
} // namespace advss
|
||||
|
||||
@@ -58,7 +58,10 @@ private slots:
|
||||
void ConditionChanged(int idx);
|
||||
|
||||
protected:
|
||||
void SetWidgetVisibility();
|
||||
|
||||
QComboBox *_condition;
|
||||
QLabel *_shutdownLimitation;
|
||||
std::shared_ptr<MacroConditionPluginState> _entryData;
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user