Safely close database connections and delete backends
Also fix NewClosure leak caused by disconnected object signals
This commit is contained in:
@@ -50,7 +50,7 @@ SubsonicBaseRequest::~SubsonicBaseRequest() {
|
||||
|
||||
while (!replies_.isEmpty()) {
|
||||
QNetworkReply *reply = replies_.takeFirst();
|
||||
disconnect(reply, 0, nullptr, 0);
|
||||
disconnect(reply, 0, this, 0);
|
||||
if (reply->isRunning()) reply->abort();
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ SubsonicRequest::~SubsonicRequest() {
|
||||
|
||||
while (!album_cover_replies_.isEmpty()) {
|
||||
QNetworkReply *reply = album_cover_replies_.takeFirst();
|
||||
disconnect(reply, 0, nullptr, 0);
|
||||
disconnect(reply, 0, this, 0);
|
||||
if (reply->isRunning()) reply->abort();
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ class SubsonicService : public InternetService {
|
||||
static const Song::Source kSource;
|
||||
|
||||
void ReloadSettings();
|
||||
void Exit();
|
||||
|
||||
Application *app() { return app_; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user