From ba1e950e630fbab4b808042f8b9e7c00729f9c79 Mon Sep 17 00:00:00 2001 From: Exeldro Date: Wed, 31 Jul 2024 12:02:07 +0200 Subject: [PATCH] Fix crash vertical outputs dereferenced --- multistream.cpp | 28 +++++++++------------------- multistream.hpp | 1 + 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/multistream.cpp b/multistream.cpp index 1430c83..e2a6ba3 100644 --- a/multistream.cpp +++ b/multistream.cpp @@ -430,6 +430,7 @@ MultistreamDock::~MultistreamDock() obs_service_release(service); } outputs.clear(); + obs_data_array_release(vertical_outputs); obs_data_release(current_config); obs_frontend_remove_event_callback(frontend_event, this); multistream_dock = nullptr; @@ -948,37 +949,26 @@ void MultistreamDock::LoadVerticalOutputs(bool firstLoad) return; } - auto outputs = (obs_data_array_t *)calldata_ptr(&cd, "outputs"); + if (vertical_outputs) + obs_data_array_release(vertical_outputs); + vertical_outputs = (obs_data_array_t *)calldata_ptr(&cd, "outputs"); + calldata_free(&cd); - auto count = obs_data_array_count(outputs); + auto count = obs_data_array_count(vertical_outputs); int idx = 0; while (auto item = verticalCanvasOutputLayout->itemAt(idx)) { auto streamGroup = item->widget(); - auto name = streamGroup->objectName(); - bool found = false; - for (size_t i = 0; i < count; i++) { - auto item = obs_data_array_item(outputs, i); - if (QString::fromUtf8(obs_data_get_string(item, "name")) == name) { - found = true; - } - obs_data_release(item); - } - if (!found) { - verticalCanvasOutputLayout->removeWidget(streamGroup); - RemoveWidget(streamGroup); - } else { - idx++; - } + verticalCanvasOutputLayout->removeWidget(streamGroup); + RemoveWidget(streamGroup); } obs_data_array_enum( - outputs, + vertical_outputs, [](obs_data_t *data, void *param) { auto d = (MultistreamDock *)param; d->LoadOutput(data, true); }, this); - obs_data_array_release(outputs); } void MultistreamDock::storeMainStreamEncoders() diff --git a/multistream.hpp b/multistream.hpp index 7e02c52..d4cee9c 100644 --- a/multistream.hpp +++ b/multistream.hpp @@ -35,6 +35,7 @@ private: std::vector oldVideo; std::vector> outputs; + obs_data_array_t *vertical_outputs = nullptr; bool exiting = false; void LoadSettingsFile();