mirror of
https://github.com/Aitum/obs-aitum-multistream.git
synced 2024-11-25 11:42:58 +01:00
Fix crash on rename
This commit is contained in:
parent
d0bdf94766
commit
1cff1f4cb9
@ -24,6 +24,9 @@
|
||||
#include "version.h"
|
||||
#include <util/dstr.h>
|
||||
|
||||
void RemoveWidget(QWidget *widget);
|
||||
void RemoveLayoutItem(QLayoutItem *item);
|
||||
|
||||
OBSBasicSettings::OBSBasicSettings(QMainWindow *parent) : QDialog(parent)
|
||||
{
|
||||
setMinimumWidth(983);
|
||||
@ -344,8 +347,7 @@ void OBSBasicSettings::AddServer(QFormLayout *outputsLayout, obs_data_t *setting
|
||||
videoEncoderIndex->addItem(QString::number(i + 1));
|
||||
}
|
||||
videoEncoderIndex->setCurrentIndex(obs_data_get_int(settings, "video_encoder_index"));
|
||||
connect(videoEncoderIndex, &QComboBox::currentIndexChanged,
|
||||
[videoEncoderIndex, settings] {
|
||||
connect(videoEncoderIndex, &QComboBox::currentIndexChanged, [videoEncoderIndex, settings] {
|
||||
if (videoEncoderIndex->currentIndex() >= 0)
|
||||
obs_data_set_int(settings, "video_encoder_index", videoEncoderIndex->currentIndex());
|
||||
});
|
||||
@ -430,16 +432,8 @@ void OBSBasicSettings::AddServer(QFormLayout *outputsLayout, obs_data_t *setting
|
||||
new QPushButton(QIcon(":/res/images/minus.svg"), QString::fromUtf8(obs_frontend_get_locale_string("Remove")));
|
||||
removeButton->setProperty("themeID", QVariant(QString::fromUtf8("removeIconSmall")));
|
||||
connect(removeButton, &QPushButton::clicked, [this, outputsLayout, serverGroup, settings] {
|
||||
if (serverGroup->layout()) {
|
||||
QLayoutItem *item;
|
||||
while ((item = serverGroup->layout()->takeAt(0)) != NULL) {
|
||||
delete item->widget();
|
||||
delete item;
|
||||
}
|
||||
delete serverGroup->layout();
|
||||
}
|
||||
outputsLayout->removeWidget(serverGroup);
|
||||
delete serverGroup;
|
||||
RemoveWidget(serverGroup);
|
||||
auto outputs = obs_data_get_array(this->settings, "outputs");
|
||||
auto count = obs_data_array_count(outputs);
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
@ -502,17 +496,7 @@ void OBSBasicSettings::LoadSettings(obs_data_t *settings)
|
||||
{
|
||||
while (mainOutputsLayout->rowCount() > 2) {
|
||||
auto i = mainOutputsLayout->takeRow(2).fieldItem;
|
||||
if (i->widget()) {
|
||||
if (i->widget()->layout()) {
|
||||
QLayoutItem *item;
|
||||
while ((item = i->widget()->layout()->takeAt(0)) != NULL) {
|
||||
delete item->widget();
|
||||
delete item;
|
||||
}
|
||||
delete i->widget()->layout();
|
||||
}
|
||||
delete i->widget();
|
||||
}
|
||||
RemoveLayoutItem(i);
|
||||
mainOutputsLayout->removeRow(2);
|
||||
}
|
||||
this->settings = settings;
|
||||
|
@ -38,6 +38,33 @@ void obs_module_unload()
|
||||
}
|
||||
}
|
||||
|
||||
void RemoveWidget(QWidget *widget);
|
||||
|
||||
void RemoveLayoutItem(QLayoutItem *item)
|
||||
{
|
||||
if (!item)
|
||||
return;
|
||||
RemoveWidget(item->widget());
|
||||
if (item->layout()) {
|
||||
while (QLayoutItem *item2 = item->layout()->takeAt(0))
|
||||
RemoveLayoutItem(item2);
|
||||
}
|
||||
delete item;
|
||||
}
|
||||
|
||||
void RemoveWidget(QWidget *widget)
|
||||
{
|
||||
if (!widget)
|
||||
return;
|
||||
if (widget->layout()) {
|
||||
while (QLayoutItem *item = widget->layout()->takeAt(0)) {
|
||||
RemoveLayoutItem(item);
|
||||
}
|
||||
delete widget->layout();
|
||||
}
|
||||
delete widget;
|
||||
}
|
||||
|
||||
MultistreamDock::MultistreamDock(QWidget *parent) : QFrame(parent)
|
||||
{
|
||||
auto l = new QVBoxLayout;
|
||||
@ -241,16 +268,8 @@ void MultistreamDock::LoadSettings()
|
||||
obs_data_release(item);
|
||||
}
|
||||
if (!found) {
|
||||
if (streamGroup->layout()) {
|
||||
while (QLayoutItem *item = streamGroup->layout()->takeAt(0)) {
|
||||
delete item->widget();
|
||||
delete item->layout();
|
||||
delete item;
|
||||
}
|
||||
delete streamGroup->layout();
|
||||
}
|
||||
mainCanvasLayout->removeWidget(streamGroup);
|
||||
delete streamGroup;
|
||||
RemoveWidget(streamGroup);
|
||||
} else {
|
||||
idx++;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user