Skip to content

Commit

Permalink
Fix crash vertical outputs dereferenced
Browse files Browse the repository at this point in the history
  • Loading branch information
exeldro committed Jul 31, 2024
1 parent 6c4d065 commit ba1e950
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
28 changes: 9 additions & 19 deletions multistream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Check failure on line 957 in multistream.cpp

View workflow job for this annotation

GitHub Actions / Build Project 🧱 / Build for macOS 🍏

unused variable 'count' [-Werror,-Wunused-variable]
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()
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;
obs_data_array_t *vertical_outputs = nullptr;
bool exiting = false;

void LoadSettingsFile();
Expand Down

0 comments on commit ba1e950

Please sign in to comment.