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
This commit is contained in:
Ruwen Hahn 2024-08-20 22:31:04 +02:00 committed by GitHub
parent bdab41cafc
commit 12fa9dce65
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View File

@ -66,8 +66,10 @@ void ModelDownloader::closeEvent(QCloseEvent *e)
{
if (!this->mPrepareToClose)
e->ignore();
else
else {
QDialog::closeEvent(e);
deleteLater();
}
}
void ModelDownloader::close()

View File

@ -50,8 +50,8 @@ protected:
private:
QVBoxLayout *layout;
QProgressBar *progress_bar;
QThread *download_thread;
ModelDownloadWorker *download_worker;
QPointer<QThread> download_thread;
QPointer<ModelDownloadWorker> download_worker;
// Callback for when the download is finished
download_finished_callback_t download_finished_callback;
bool mPrepareToClose;