Safely close database connections and delete backends

Also fix NewClosure leak caused by disconnected object signals
This commit is contained in:
Jonas Kvinge
2019-07-24 19:16:51 +02:00
parent bd78e8c275
commit b5eb13449b
47 changed files with 490 additions and 53 deletions

View File

@@ -95,7 +95,14 @@ SubsonicService::SubsonicService(Application *app, QObject *parent)
}
SubsonicService::~SubsonicService() {
collection_backend_->deleteLater();
delete collection_backend_;
}
void SubsonicService::Exit() {
connect(collection_backend_, SIGNAL(ExitFinished()), this, SIGNAL(ExitFinished()));
collection_backend_->ExitAsync();
}
void SubsonicService::ShowConfig() {
@@ -317,8 +324,8 @@ void SubsonicService::CheckConfiguration() {
void SubsonicService::ResetSongsRequest() {
if (songs_request_.get()) {
disconnect(songs_request_.get(), 0, nullptr, 0);
if (songs_request_.get()) { // WARNING: Don't disconnect everything. NewClosure() relies on destroyed()!!!
disconnect(songs_request_.get(), 0, this, 0);
disconnect(this, 0, songs_request_.get(), 0);
songs_request_.reset();
}