Minor refactor for creation of sub-windows

This refactors the sub-window code a bit so that instead of deleting the
window pointers, it calls QWidget::close() on them to safely trigger a
normal close on them instead (which will also delete them).
Moves setting the DeleteOnClose flag from inside of the Dialog classes
into the OBSBasic class, to make that behaviour more obvious.
This commit is contained in:
BtbN 2014-07-22 22:16:57 +02:00
parent dfa2d992c1
commit 34b67db50f
4 changed files with 25 additions and 17 deletions

View file

@ -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()

View file

@ -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);

View file

@ -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);

View file

@ -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()));