Skip to content

Commit

Permalink
Fix crash on shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
exeldro committed Jul 30, 2024
1 parent c64f09b commit dbeab14
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
20 changes: 13 additions & 7 deletions multistream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,15 @@ MultistreamDock::~MultistreamDock()
{
for (auto it = outputs.begin(); it != outputs.end(); it++) {
auto old = std::get<obs_output_t *>(*it);
signal_handler_t *signal = obs_output_get_signal_handler(old);
signal_handler_disconnect(signal, "start", stream_output_start, this);
signal_handler_disconnect(signal, "stop", stream_output_stop, this);
auto service = obs_output_get_service(old);
if (obs_output_active(old)) {
obs_output_force_stop(old);
}
obs_output_release(old);
if (!exiting)
obs_output_release(old);
obs_service_release(service);
}
outputs.clear();
Expand All @@ -437,9 +441,11 @@ void MultistreamDock::frontend_event(enum obs_frontend_event event, void *privat
auto md = (MultistreamDock *)private_data;
if (event == OBS_FRONTEND_EVENT_PROFILE_CHANGED || event == OBS_FRONTEND_EVENT_FINISHED_LOADING) {
md->LoadSettingsFile();
} else if (event == OBS_FRONTEND_EVENT_PROFILE_CHANGING || event == OBS_FRONTEND_EVENT_PROFILE_RENAMED ||
event == OBS_FRONTEND_EVENT_EXIT) {
} else if (event == OBS_FRONTEND_EVENT_PROFILE_CHANGING || event == OBS_FRONTEND_EVENT_PROFILE_RENAMED) {
md->SaveSettings();
} else if (event == OBS_FRONTEND_EVENT_EXIT) {
md->SaveSettings();
md->exiting = true;
} else if (event == OBS_FRONTEND_EVENT_STREAMING_STARTING || event == OBS_FRONTEND_EVENT_STREAMING_STARTED) {
md->mainStreamButton->setChecked(true);
md->outputButtonStyle(md->mainStreamButton);
Expand Down Expand Up @@ -589,8 +595,7 @@ void MultistreamDock::LoadOutput(obs_data_t *data, bool vertical)
if (std::get<std::string>(*it) != name)
continue;
obs_queue_task(
OBS_TASK_GRAPHICS,
[](void *param) { obs_output_stop((obs_output_t *)param); },
OBS_TASK_GRAPHICS, [](void *param) { obs_output_stop((obs_output_t *)param); },
std::get<obs_output *>(*it), false);
}
}
Expand Down Expand Up @@ -899,8 +904,9 @@ void MultistreamDock::stream_output_stop(void *data, calldata_t *calldata)
},
Qt::QueuedConnection);
}
QMetaObject::invokeMethod(
button, [output] { obs_output_release(output); }, Qt::QueuedConnection);
if (!md->exiting)
QMetaObject::invokeMethod(
button, [output] { obs_output_release(output); }, Qt::QueuedConnection);
md->outputs.erase(it);
break;
}
Expand Down
1 change: 1 addition & 0 deletions multistream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class MultistreamDock : public QFrame {
std::vector<video_t *> oldVideo;

std::vector<std::tuple<std::string, obs_output_t *, QPushButton *>> outputs;
bool exiting = false;

void LoadSettingsFile();
void LoadSettings();
Expand Down

0 comments on commit dbeab14

Please sign in to comment.