diff --git a/switcher.cpp b/switcher.cpp index 12f3ac35..bcac2813 100644 --- a/switcher.cpp +++ b/switcher.cpp @@ -64,7 +64,6 @@ void Switcher::switcherThreadFunc() { else { //switch scene sceneName = sceneRoundTrip.at(roundTripPos + 1); - obs_source_t * transitionUsed = obs_get_output_source(0); obs_source_t *source = obs_get_source_by_name(sceneName.c_str()); if (source != NULL) { //create transition to new scene @@ -372,8 +371,7 @@ string Switcher::GetActiveWindowTitle() //tell the thread to stop void Switcher::stop() { isRunning = false; - switcherThread.join(); - return; + if (switcherThread.joinable()) switcherThread.join(); } string Switcher::getSettingsFilePath() @@ -386,6 +384,11 @@ void Switcher::setSettingsFilePath(string path) settings.setSettingsFilePath(path); } +Switcher::~Switcher() +{ + stop(); +} + bool Switcher::getIsRunning() { return isRunning; diff --git a/switcher.h b/switcher.h index b337e39f..8cd4223a 100644 --- a/switcher.h +++ b/switcher.h @@ -17,6 +17,7 @@ public: string getSettingsFilePath(); void setSettingsFilePath(string path); thread switcherThread; + ~Switcher(); private: bool isRunning = true; Settings settings;