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