diff --git a/obs/window-basic-properties.cpp b/obs/window-basic-properties.cpp index a70d29a82..0bf903cda 100644 --- a/obs/window-basic-properties.cpp +++ b/obs/window-basic-properties.cpp @@ -55,6 +55,9 @@ OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_) if (cx > 400 && cy > 400) resize(cx, cy); + /* The OBSData constructor increments the reference once */ + obs_data_release(oldSettings); + OBSData settings = obs_source_get_settings(source); obs_data_apply(oldSettings, settings); obs_data_release(settings); @@ -193,6 +196,32 @@ void OBSBasicProperties::timerEvent(QTimerEvent *event) } } +void OBSBasicProperties::Cleanup() +{ + // remove draw callback and release display in case our drawable + // surfaces go away before the destructor gets called + obs_display_remove_draw_callback(display, + OBSBasicProperties::DrawPreview, this); + display = nullptr; + + config_set_int(App()->GlobalConfig(), "PropertiesWindow", "cx", + width()); + config_set_int(App()->GlobalConfig(), "PropertiesWindow", "cy", + height()); +} + +void OBSBasicProperties::reject() +{ + if (!acceptClicked && (CheckSettings() != 0)) { + if (!ConfirmQuit()) { + return; + } + } + + Cleanup(); + done(0); +} + void OBSBasicProperties::closeEvent(QCloseEvent *event) { if (!acceptClicked && (CheckSettings() != 0)) { @@ -206,18 +235,7 @@ void OBSBasicProperties::closeEvent(QCloseEvent *event) if (!event->isAccepted()) return; - obs_data_release(oldSettings); - - // remove draw callback and release display in case our drawable - // surfaces go away before the destructor gets called - obs_display_remove_draw_callback(display, - OBSBasicProperties::DrawPreview, this); - display = nullptr; - - config_set_int(App()->GlobalConfig(), "PropertiesWindow", "cx", - width()); - config_set_int(App()->GlobalConfig(), "PropertiesWindow", "cy", - height()); + Cleanup(); } void OBSBasicProperties::Init() diff --git a/obs/window-basic-properties.hpp b/obs/window-basic-properties.hpp index 8bce6fe00..4d191030e 100644 --- a/obs/window-basic-properties.hpp +++ b/obs/window-basic-properties.hpp @@ -50,6 +50,7 @@ private: static void DrawPreview(void *data, uint32_t cx, uint32_t cy); bool ConfirmQuit(); int CheckSettings(); + void Cleanup(); private slots: void OnPropertiesResized(); @@ -65,4 +66,5 @@ protected: virtual void resizeEvent(QResizeEvent *event) override; virtual void timerEvent(QTimerEvent *event) override; virtual void closeEvent(QCloseEvent *event) override; + virtual void reject() override; };