diff --git a/ActiveSceneDock.cpp b/ActiveSceneDock.cpp index 556306f..85386a7 100644 --- a/ActiveSceneDock.cpp +++ b/ActiveSceneDock.cpp @@ -27,6 +27,11 @@ ActiveSceneDock::ActiveSceneDock(QWidget *parent) ActiveSceneDock::~ActiveSceneDock() { if (currentScene) { + auto *signalHandler = obs_source_get_signal_handler(currentScene); + if (signalHandler) { + signal_handler_disconnect(signalHandler, "rename", + &ActiveSceneDock::currentSceneRenamed, this); + } obs_source_release(currentScene); } } @@ -37,6 +42,11 @@ void ActiveSceneDock::updateCurrentScene(obs_source_t *newScene, return; } if (currentScene) { + auto *signalHandler = obs_source_get_signal_handler(currentScene); + if (signalHandler) { + signal_handler_disconnect(signalHandler, "rename", + &ActiveSceneDock::currentSceneRenamed, this); + } obs_source_release(currentScene); currentScene = nullptr; } @@ -47,6 +57,12 @@ void ActiveSceneDock::updateCurrentScene(obs_source_t *newScene, obs_source_addref(newScene); currentScene = newScene; + auto *signalHandler = obs_source_get_signal_handler(newScene); + if (signalHandler) { + signal_handler_connect(signalHandler, "rename", + &ActiveSceneDock::currentSceneRenamed, this); + } + currentSceneTimer.start(); if (timerId < 0) { timerId = startTimer(75); @@ -70,6 +86,14 @@ void ActiveSceneDock::timerEvent(QTimerEvent *event) { } } +void ActiveSceneDock::currentSceneRenamed(void *data, calldata_t *cd) { + auto *dock = static_cast(data); + const auto *newName = calldata_string(cd, "new_name"); + if (newName) { + dock->sceneLabel->setText(QString::fromUtf8(newName)); + } +} + void ActiveSceneDock::updateTimerText() { qint64 elapsed = 0; if (currentScene) { diff --git a/ActiveSceneDock.hpp b/ActiveSceneDock.hpp index a7d1856..1c92e50 100644 --- a/ActiveSceneDock.hpp +++ b/ActiveSceneDock.hpp @@ -20,5 +20,6 @@ class ActiveSceneDock : public QDockWidget { protected: void timerEvent(QTimerEvent *event) override; + static void currentSceneRenamed(void *data, calldata_t *cd); void updateTimerText(); }; diff --git a/CHANGELOG.md b/CHANGELOG.md index 08eeb5b..bf4faf4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- Update scene label when scene is renamed + ## 0.1.1 - Change dock title to "Active Scene" from "Scene Timer"