mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
events: fix crash when switching between scene collections
This commit is contained in:
parent
73f00ca195
commit
c34dff17ff
@ -84,8 +84,8 @@ WSEvents::WSEvents(WSServer* srv) {
|
|||||||
connect(sceneList, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
|
connect(sceneList, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
|
||||||
this, SLOT(SelectedSceneChanged(QListWidgetItem*, QListWidgetItem*)));
|
this, SLOT(SelectedSceneChanged(QListWidgetItem*, QListWidgetItem*)));
|
||||||
|
|
||||||
transitionHandler = nullptr;
|
currentScene = nullptr;
|
||||||
sceneHandler = nullptr;
|
currentTransition = nullptr;
|
||||||
|
|
||||||
QTimer::singleShot(1000, this, SLOT(deferredInitOperations()));
|
QTimer::singleShot(1000, this, SLOT(deferredInitOperations()));
|
||||||
|
|
||||||
@ -221,41 +221,52 @@ void WSEvents::broadcastUpdate(const char* updateType,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void WSEvents::connectTransitionSignals(obs_source_t* transition) {
|
void WSEvents::connectTransitionSignals(obs_source_t* transition) {
|
||||||
if (transitionHandler) {
|
signal_handler_t* sh = nullptr;
|
||||||
signal_handler_disconnect(transitionHandler,
|
|
||||||
|
if (currentTransition) {
|
||||||
|
sh = obs_source_get_signal_handler(currentTransition);
|
||||||
|
signal_handler_disconnect(sh,
|
||||||
"transition_start", OnTransitionBegin, this);
|
"transition_start", OnTransitionBegin, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!transitionIsCut(transition)) {
|
if (!transitionIsCut(transition)) {
|
||||||
transitionHandler = obs_source_get_signal_handler(transition);
|
currentTransition = transition;
|
||||||
signal_handler_connect(transitionHandler,
|
|
||||||
|
sh = obs_source_get_signal_handler(currentTransition);
|
||||||
|
signal_handler_connect(sh,
|
||||||
"transition_start", OnTransitionBegin, this);
|
"transition_start", OnTransitionBegin, this);
|
||||||
} else {
|
} else {
|
||||||
transitionHandler = nullptr;
|
currentTransition = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WSEvents::connectSceneSignals(obs_source_t* scene) {
|
void WSEvents::connectSceneSignals(obs_source_t* scene) {
|
||||||
if (sceneHandler) {
|
signal_handler_t* sh = nullptr;
|
||||||
signal_handler_disconnect(sceneHandler,
|
|
||||||
|
if (currentScene) {
|
||||||
|
sh = obs_source_get_signal_handler(currentScene);
|
||||||
|
|
||||||
|
signal_handler_disconnect(sh,
|
||||||
"reorder", OnSceneReordered, this);
|
"reorder", OnSceneReordered, this);
|
||||||
signal_handler_disconnect(sceneHandler,
|
signal_handler_disconnect(sh,
|
||||||
"item_add", OnSceneItemAdd, this);
|
"item_add", OnSceneItemAdd, this);
|
||||||
signal_handler_disconnect(sceneHandler,
|
signal_handler_disconnect(sh,
|
||||||
"item_remove", OnSceneItemDelete, this);
|
"item_remove", OnSceneItemDelete, this);
|
||||||
signal_handler_disconnect(sceneHandler,
|
signal_handler_disconnect(sh,
|
||||||
"item_visible", OnSceneItemVisibilityChanged, this);
|
"item_visible", OnSceneItemVisibilityChanged, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
currentScene = scene;
|
||||||
|
|
||||||
// TODO : connect to all scenes, not just the current one.
|
// TODO : connect to all scenes, not just the current one.
|
||||||
sceneHandler = obs_source_get_signal_handler(scene);
|
sh = obs_source_get_signal_handler(currentScene);
|
||||||
signal_handler_connect(sceneHandler,
|
signal_handler_connect(sh,
|
||||||
"reorder", OnSceneReordered, this);
|
"reorder", OnSceneReordered, this);
|
||||||
signal_handler_connect(sceneHandler,
|
signal_handler_connect(sh,
|
||||||
"item_add", OnSceneItemAdd, this);
|
"item_add", OnSceneItemAdd, this);
|
||||||
signal_handler_connect(sceneHandler,
|
signal_handler_connect(sh,
|
||||||
"item_remove", OnSceneItemDelete, this);
|
"item_remove", OnSceneItemDelete, this);
|
||||||
signal_handler_connect(sceneHandler,
|
signal_handler_connect(sh,
|
||||||
"item_visible", OnSceneItemVisibilityChanged, this);
|
"item_visible", OnSceneItemVisibilityChanged, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -335,8 +346,8 @@ void WSEvents::OnSceneListChange() {
|
|||||||
void WSEvents::OnSceneCollectionChange() {
|
void WSEvents::OnSceneCollectionChange() {
|
||||||
broadcastUpdate("SceneCollectionChanged");
|
broadcastUpdate("SceneCollectionChanged");
|
||||||
|
|
||||||
sceneHandler = nullptr;
|
currentScene = nullptr;
|
||||||
transitionHandler = nullptr;
|
currentTransition = nullptr;
|
||||||
|
|
||||||
OnTransitionListChange();
|
OnTransitionListChange();
|
||||||
OnTransitionChange();
|
OnTransitionChange();
|
||||||
|
@ -53,8 +53,8 @@ class WSEvents : public QObject {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
WSServer* _srv;
|
WSServer* _srv;
|
||||||
signal_handler_t* transitionHandler;
|
OBSSource currentScene;
|
||||||
signal_handler_t* sceneHandler;
|
OBSSource currentTransition;
|
||||||
|
|
||||||
bool pulse;
|
bool pulse;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user