From 7d8a15f2dbc31207f227bb93f483a7cb6c3fde30 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Mon, 30 Jun 2008 12:38:35 +0000 Subject: [PATCH] fixed more leaks git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1221 0778d3d1-df1d-0410-868b-ea421aaaa00d --- ChangeLog | 17 +++++++++++------ include/mv_base.h | 14 ++++++++++---- plugins/ladspa_effect/ladspa_effect.cpp | 6 +++--- src/core/base64.cpp | 1 + src/core/effect.cpp | 7 +++++++ src/core/engine.cpp | 7 ++++++- src/core/ladspa_manager.cpp | 4 ++-- 7 files changed, 40 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index af115274d..472b78d6f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,16 +2,21 @@ * include/automatable_model.h: * include/combobox_model.h: - * include/piano_roll.h: * include/mv_base.h: - * src/gui/piano_roll.cpp: + * include/piano_roll.h: + * src/core/base64.cpp: + * src/core/effect.cpp: + * src/core/engine.cpp: + * src/core/fx_mixer.cpp: + * src/core/instrument_functions.cpp: + * src/core/ladspa_manager.cpp: + * src/core/mv_base.cpp: + * src/gui/automation_editor.cpp: * src/gui/main_window.cpp: + * src/gui/piano_roll.cpp: * src/gui/widgets/combobox.cpp: * src/gui/widgets/group_box.cpp: - * src/gui/automation_editor.cpp: - * src/core/instrument_functions.cpp: - * src/core/mv_base.cpp: - * src/core/fx_mixer.cpp: + * plugins/ladspa_effect/ladspa_effect.cpp: fixed various leaks I found using Valgrind 2008-06-30 Paul Giblock diff --git a/include/mv_base.h b/include/mv_base.h index eae16eaff..320004767 100644 --- a/include/mv_base.h +++ b/include/mv_base.h @@ -27,6 +27,7 @@ #define _MV_BASE_H #include +#include #include "export.h" @@ -97,19 +98,24 @@ public: inline model * getModel( void ) { - return( m_model ); + return( m_model.data() ); + } + + inline const model * getModel( void ) const + { + return( m_model.data() ); } template T * castModel( void ) { - return( dynamic_cast( m_model ) ); + return( dynamic_cast( getModel() ) ); } template const T * castModel( void ) const { - return( dynamic_cast( m_model ) ); + return( dynamic_cast( getModel() ) ); } @@ -129,7 +135,7 @@ protected: private: QWidget * m_widget; - model * m_model; + QPointer m_model; } ; diff --git a/plugins/ladspa_effect/ladspa_effect.cpp b/plugins/ladspa_effect/ladspa_effect.cpp index 52f2f1e29..75a11d776 100644 --- a/plugins/ladspa_effect/ladspa_effect.cpp +++ b/plugins/ladspa_effect/ladspa_effect.cpp @@ -325,7 +325,7 @@ void ladspaEffect::pluginInstantiation( void ) } else { - p->buffer = new LADSPA_Data; + p->buffer = new LADSPA_Data[1]; if( manager->isPortInput( m_key, port ) ) { @@ -510,8 +510,8 @@ void ladspaEffect::pluginDestruction( void ) manager->cleanup( m_key, m_handles[proc] ); for( int port = 0; port < m_portCount; port++ ) { - free( m_ports[proc][port]->buffer ); - free( m_ports[proc][port] ); + delete[] m_ports[proc][port]->buffer; + delete m_ports[proc][port]; } m_ports[proc].clear(); } diff --git a/src/core/base64.cpp b/src/core/base64.cpp index e222c5226..970634566 100644 --- a/src/core/base64.cpp +++ b/src/core/base64.cpp @@ -69,6 +69,7 @@ QVariant decode( const QString & _b64, QVariant::Type _force_type ) in.setVersion( QDataStream::Qt_3_3 ); in >> ret; } + delete[] dst; return( ret ); } diff --git a/src/core/effect.cpp b/src/core/effect.cpp index 97bce83e1..4beb4a31b 100644 --- a/src/core/effect.cpp +++ b/src/core/effect.cpp @@ -56,6 +56,13 @@ effect::effect( const plugin::descriptor * _desc, effect::~effect() { + for( int i = 0; i < 2; ++i ) + { + if( m_srcState[i] != NULL ) + { + src_delete( m_srcState[i] ); + } + } } diff --git a/src/core/engine.cpp b/src/core/engine.cpp index 28686c3de..57115587f 100644 --- a/src/core/engine.cpp +++ b/src/core/engine.cpp @@ -131,9 +131,11 @@ void engine::destroy( void ) presetPreviewPlayHandle::cleanup(); instrumentTrackView::cleanupWindowPool(); - delete s_song; + s_song->clearAllTracks(); delete s_bbTrackContainer; + s_bbTrackContainer = NULL; delete s_dummyTC; + s_dummyTC = NULL; delete s_mixer; s_mixer = NULL; @@ -147,6 +149,9 @@ void engine::destroy( void ) s_projectJournal = NULL; s_mainWindow = NULL; + delete s_song; + s_song = NULL; + delete configManager::inst(); } diff --git a/src/core/ladspa_manager.cpp b/src/core/ladspa_manager.cpp index 0f28de069..e52338761 100644 --- a/src/core/ladspa_manager.cpp +++ b/src/core/ladspa_manager.cpp @@ -741,8 +741,8 @@ bool ladspaManager::isInteger( const ladspa_key_t & _plugin, QString ladspaManager::getPortName( const ladspa_key_t & _plugin, Uint32 _port ) { - if( m_ladspaManagerMap.contains( _plugin ) - && _port < getPortCount( _plugin ) ) + if( m_ladspaManagerMap.contains( _plugin ) && + _port < getPortCount( _plugin ) ) { LADSPA_Descriptor_Function descriptorFunction = m_ladspaManagerMap[_plugin]->descriptorFunction;