Safely close database connections and delete backends
Also fix NewClosure leak caused by disconnected object signals
This commit is contained in:
@@ -182,13 +182,35 @@ TidalService::~TidalService() {
|
||||
|
||||
while (!stream_url_requests_.isEmpty()) {
|
||||
TidalStreamURLRequest *stream_url_req = stream_url_requests_.takeFirst();
|
||||
disconnect(stream_url_req, 0, nullptr, 0);
|
||||
disconnect(stream_url_req, 0, this, 0);
|
||||
stream_url_req->deleteLater();
|
||||
}
|
||||
|
||||
artists_collection_backend_->deleteLater();
|
||||
albums_collection_backend_->deleteLater();
|
||||
songs_collection_backend_->deleteLater();
|
||||
delete artists_collection_backend_;
|
||||
delete albums_collection_backend_;
|
||||
delete songs_collection_backend_;
|
||||
|
||||
}
|
||||
|
||||
void TidalService::Exit() {
|
||||
|
||||
wait_for_exit_ << artists_collection_backend_ << albums_collection_backend_ << songs_collection_backend_;
|
||||
|
||||
connect(artists_collection_backend_, SIGNAL(ExitFinished()), this, SLOT(ExitReceived()));
|
||||
connect(albums_collection_backend_, SIGNAL(ExitFinished()), this, SLOT(ExitReceived()));
|
||||
connect(songs_collection_backend_, SIGNAL(ExitFinished()), this, SLOT(ExitReceived()));
|
||||
|
||||
artists_collection_backend_->ExitAsync();
|
||||
albums_collection_backend_->ExitAsync();
|
||||
songs_collection_backend_->ExitAsync();
|
||||
|
||||
}
|
||||
|
||||
void TidalService::ExitReceived() {
|
||||
|
||||
disconnect(sender(), 0, this, 0);
|
||||
wait_for_exit_.removeAll(sender());
|
||||
if (wait_for_exit_.isEmpty()) emit ExitFinished();
|
||||
|
||||
}
|
||||
|
||||
@@ -639,7 +661,7 @@ void TidalService::TryLogin() {
|
||||
void TidalService::ResetArtistsRequest() {
|
||||
|
||||
if (artists_request_.get()) {
|
||||
disconnect(artists_request_.get(), 0, nullptr, 0);
|
||||
disconnect(artists_request_.get(), 0, this, 0);
|
||||
disconnect(this, 0, artists_request_.get(), 0);
|
||||
artists_request_.reset();
|
||||
}
|
||||
@@ -694,7 +716,7 @@ void TidalService::ArtistsUpdateProgressReceived(const int id, const int progres
|
||||
void TidalService::ResetAlbumsRequest() {
|
||||
|
||||
if (albums_request_.get()) {
|
||||
disconnect(albums_request_.get(), 0, nullptr, 0);
|
||||
disconnect(albums_request_.get(), 0, this, 0);
|
||||
disconnect(this, 0, albums_request_.get(), 0);
|
||||
albums_request_.reset();
|
||||
}
|
||||
@@ -747,7 +769,7 @@ void TidalService::AlbumsUpdateProgressReceived(const int id, const int progress
|
||||
void TidalService::ResetSongsRequest() {
|
||||
|
||||
if (songs_request_.get()) {
|
||||
disconnect(songs_request_.get(), 0, nullptr, 0);
|
||||
disconnect(songs_request_.get(), 0, this, 0);
|
||||
disconnect(this, 0, songs_request_.get(), 0);
|
||||
songs_request_.reset();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user