diff --git a/obs/window-basic-main.cpp b/obs/window-basic-main.cpp index 669576963..483a594af 100644 --- a/obs/window-basic-main.cpp +++ b/obs/window-basic-main.cpp @@ -588,8 +588,11 @@ OBSBasic::~OBSBasic() delete cpuUsageTimer; os_cpu_usage_info_destroy(cpuUsageInfo); - delete properties; - delete transformWindow; + if (properties) + delete properties; + + if (transformWindow) + delete transformWindow; ClearVolumeControls(); ui->sources->clear(); @@ -648,11 +651,18 @@ void OBSBasic::InsertSceneItem(obs_sceneitem_t item) ui->sources->setCurrentRow(0); /* if the source was just created, open properties dialog */ - if (sourceSceneRefs[source] == 0 && loaded) { - delete properties; - properties = new OBSBasicProperties(this, source); - properties->Init(); - } + if (sourceSceneRefs[source] == 0 && loaded) + CreatePropertiesWindow(source); +} + +void OBSBasic::CreatePropertiesWindow(obs_source_t source) +{ + if (properties) + properties->close(); + + properties = new OBSBasicProperties(this, source); + properties->Init(); + properties->setAttribute(Qt::WA_DeleteOnClose, true); } /* Qt callbacks for invokeMethod */ @@ -1674,11 +1684,8 @@ void OBSBasic::on_actionSourceProperties_triggered() OBSSceneItem item = GetCurrentSceneItem(); OBSSource source = obs_sceneitem_getsource(item); - if (source) { - delete properties; - properties = new OBSBasicProperties(this, source); - properties->Init(); - } + if (source) + CreatePropertiesWindow(source); } void OBSBasic::on_actionSourceUp_triggered() @@ -2112,9 +2119,12 @@ config_t OBSBasic::Config() const void OBSBasic::on_actionEditTransform_triggered() { - delete transformWindow; + if (transformWindow) + transformWindow->close(); + transformWindow = new OBSBasicTransform(this); transformWindow->show(); + transformWindow->setAttribute(Qt::WA_DeleteOnClose, true); } void OBSBasic::on_actionResetTransform_triggered() diff --git a/obs/window-basic-main.hpp b/obs/window-basic-main.hpp index 673ee99f2..52371968f 100644 --- a/obs/window-basic-main.hpp +++ b/obs/window-basic-main.hpp @@ -140,6 +140,8 @@ private: void TempStreamOutput(const char *url, const char *key, int vBitrate, int aBitrate); + void CreatePropertiesWindow(obs_source_t source); + public slots: void StreamingStart(); void StreamingStop(int errorcode); diff --git a/obs/window-basic-properties.cpp b/obs/window-basic-properties.cpp index fa77e2be3..795f958ea 100644 --- a/obs/window-basic-properties.cpp +++ b/obs/window-basic-properties.cpp @@ -36,8 +36,6 @@ OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_) removedSignal (obs_source_signalhandler(source), "remove", OBSBasicProperties::SourceRemoved, this) { - setAttribute(Qt::WA_DeleteOnClose); - ui->setupUi(this); OBSData settings = obs_source_getsettings(source); diff --git a/obs/window-basic-transform.cpp b/obs/window-basic-transform.cpp index f68ce24b1..5dc29617c 100644 --- a/obs/window-basic-transform.cpp +++ b/obs/window-basic-transform.cpp @@ -37,8 +37,6 @@ OBSBasicTransform::OBSBasicTransform(OBSBasic *parent) ui (new Ui::OBSBasicTransform), main (parent) { - setAttribute(Qt::WA_DeleteOnClose); - ui->setupUi(this); HookWidget(ui->positionX, DSCROLL_CHANGED, SLOT(OnControlChanged()));