Fix memory leaks

This commit is contained in:
Jonas Kvinge
2019-07-22 20:53:05 +02:00
parent 2df21081a1
commit bd78e8c275
33 changed files with 186 additions and 74 deletions

View File

@@ -31,12 +31,18 @@
#include "internetservice.h"
InternetServices::InternetServices(QObject *parent) : QObject(parent) {}
InternetServices::~InternetServices() {}
InternetServices::~InternetServices() {
while (!services_.isEmpty()) {
delete services_.take(services_.firstKey());
}
}
void InternetServices::AddService(InternetService *service) {
services_.insert(service->source(), service);
connect(service, SIGNAL(destroyed()), SLOT(ServiceDeleted()));
if (service->has_initial_load_settings()) service->InitialLoadSettings();
else service->ReloadSettings();
@@ -50,12 +56,7 @@ void InternetServices::RemoveService(InternetService *service) {
services_.remove(service->source());
disconnect(service, 0, this, 0);
}
void InternetServices::ServiceDeleted() {
InternetService *service = qobject_cast<InternetService*>(sender());
if (service) RemoveService(service);
qLog(Debug) << "Removed internet service" << service->name();
}