From 12fa9dce6568c2868c8c7a5d71c6ad41794a6f7e Mon Sep 17 00:00:00 2001 From: Ruwen Hahn Date: Tue, 20 Aug 2024 22:31:04 +0200 Subject: [PATCH] Fix model downloader crash on shutdown (#155) * Fix `ModelDownloader` not being aware of child object deletions * Delete `ModelDownloader` after it's done processing Otherwise this is only deleted when OBS exits, effectively leaking memory --- src/model-utils/model-downloader-ui.cpp | 4 +++- src/model-utils/model-downloader-ui.h | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/model-utils/model-downloader-ui.cpp b/src/model-utils/model-downloader-ui.cpp index 2dac46e..a428e20 100644 --- a/src/model-utils/model-downloader-ui.cpp +++ b/src/model-utils/model-downloader-ui.cpp @@ -66,8 +66,10 @@ void ModelDownloader::closeEvent(QCloseEvent *e) { if (!this->mPrepareToClose) e->ignore(); - else + else { QDialog::closeEvent(e); + deleteLater(); + } } void ModelDownloader::close() diff --git a/src/model-utils/model-downloader-ui.h b/src/model-utils/model-downloader-ui.h index 20521b6..aaa0752 100644 --- a/src/model-utils/model-downloader-ui.h +++ b/src/model-utils/model-downloader-ui.h @@ -50,8 +50,8 @@ public slots: private: QVBoxLayout *layout; QProgressBar *progress_bar; - QThread *download_thread; - ModelDownloadWorker *download_worker; + QPointer download_thread; + QPointer download_worker; // Callback for when the download is finished download_finished_callback_t download_finished_callback; bool mPrepareToClose;