From 3365c7c21729aefa6180788ffc47aaec7402dff1 Mon Sep 17 00:00:00 2001 From: David Sansome Date: Fri, 28 May 2010 19:51:51 +0000 Subject: [PATCH] Fix a few memory leaks --- src/core/player.cpp | 4 ++++ src/core/player.h | 1 + src/engines/gstengine.cpp | 11 ++++++----- src/library/library.cpp | 3 ++- src/ui/systemtrayicon.cpp | 2 -- src/ui/systemtrayicon.h | 1 - 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/core/player.cpp b/src/core/player.cpp index e0d962083..aaee93913 100644 --- a/src/core/player.cpp +++ b/src/core/player.cpp @@ -96,6 +96,10 @@ Player::Player(PlaylistManager* playlists, LastFMService* lastfm, #endif } +Player::~Player() { + delete engine_; +} + EngineBase* Player::createEngine(Engine::Type engine) { switch(engine) { diff --git a/src/core/player.h b/src/core/player.h index ec09c89a9..087c1725c 100644 --- a/src/core/player.h +++ b/src/core/player.h @@ -54,6 +54,7 @@ class Player : public QObject { public: Player(PlaylistManager* playlists, LastFMService* lastfm, Engine::Type engine, QObject* parent = 0); + ~Player(); EngineBase* createEngine(Engine::Type engine); void Init(); diff --git a/src/engines/gstengine.cpp b/src/engines/gstengine.cpp index 01095e18e..11114bebe 100644 --- a/src/engines/gstengine.cpp +++ b/src/engines/gstengine.cpp @@ -609,20 +609,21 @@ GstEngine::PluginDetailsList PluginDetailsList ret; GstRegistry* registry = gst_registry_get_default(); - GList* features = + GList* const features = gst_registry_get_feature_list(registry, GST_TYPE_ELEMENT_FACTORY); - while (features) { - GstElementFactory* factory = GST_ELEMENT_FACTORY(features->data); + GList* p = features; + while (p) { + GstElementFactory* factory = GST_ELEMENT_FACTORY(p->data); if (QString(factory->details.klass).contains(classname)) { PluginDetails details; - details.name = QString::fromUtf8(GST_PLUGIN_FEATURE_NAME(features->data)); + details.name = QString::fromUtf8(GST_PLUGIN_FEATURE_NAME(p->data)); details.long_name = QString::fromUtf8(factory->details.longname); details.description = QString::fromUtf8(factory->details.description); details.author = QString::fromUtf8(factory->details.author); ret << details; } - features = g_list_next ( features ); + p = g_list_next(p); } gst_plugin_feature_list_free(features); diff --git a/src/library/library.cpp b/src/library/library.cpp index 55cf8e484..ded3d5a88 100644 --- a/src/library/library.cpp +++ b/src/library/library.cpp @@ -23,7 +23,8 @@ const char* Library::kDirsTable = "directories"; const char* Library::kSubdirsTable = "subdirectories"; Library::Library(Database *db, QObject *parent) - : backend_(new LibraryBackend(db, kSongsTable, kDirsTable, kSubdirsTable, this)), + : QObject(parent), + backend_(new LibraryBackend(db, kSongsTable, kDirsTable, kSubdirsTable, this)), model_(new LibraryModel(backend_, parent)), watcher_factory_(new BackgroundThreadFactoryImplementation), watcher_(NULL) diff --git a/src/ui/systemtrayicon.cpp b/src/ui/systemtrayicon.cpp index abb08ece6..8e97ca04f 100644 --- a/src/ui/systemtrayicon.cpp +++ b/src/ui/systemtrayicon.cpp @@ -36,8 +36,6 @@ SystemTrayIcon::SystemTrayIcon(QObject* parent) #endif } -SystemTrayIcon::~SystemTrayIcon() {} - bool SystemTrayIcon::event(QEvent* event) { if (event->type() == QEvent::Wheel) { emit WheelEvent(static_cast(event)->delta()); diff --git a/src/ui/systemtrayicon.h b/src/ui/systemtrayicon.h index 47c1821e1..2bb678d9e 100644 --- a/src/ui/systemtrayicon.h +++ b/src/ui/systemtrayicon.h @@ -24,7 +24,6 @@ class SystemTrayIcon : public QSystemTrayIcon { public: SystemTrayIcon(QObject* parent = 0); - virtual ~SystemTrayIcon(); virtual bool event(QEvent* event);