Skip to content
Snippets Groups Projects
Commit 0bcbca12 authored by Emmanuel Lepage Vallee's avatar Emmanuel Lepage Vallee
Browse files

[ #36391 ] Fix 2 minor memory leaks

parent 3b77118b
No related branches found
No related tags found
No related merge requests found
...@@ -113,11 +113,11 @@ QModelIndex AudioCodecModel::addAudioCodec() { ...@@ -113,11 +113,11 @@ QModelIndex AudioCodecModel::addAudioCodec() {
///Remove audio codec at 'idx' ///Remove audio codec at 'idx'
void AudioCodecModel::removeAudioCodec(QModelIndex idx) { void AudioCodecModel::removeAudioCodec(QModelIndex idx) {
qDebug() << "REMOVING" << idx.row() << m_lAudioCodecs.size();
if (idx.isValid()) { if (idx.isValid()) {
AudioCodecData* d = m_lAudioCodecs[idx.row()];
m_lAudioCodecs.removeAt(idx.row()); m_lAudioCodecs.removeAt(idx.row());
delete d;
emit dataChanged(idx, index(m_lAudioCodecs.size()-1,0)); emit dataChanged(idx, index(m_lAudioCodecs.size()-1,0));
qDebug() << "DONE" << m_lAudioCodecs.size();
} }
else { else {
qDebug() << "Failed to remove an invalid audio codec"; qDebug() << "Failed to remove an invalid audio codec";
...@@ -127,8 +127,10 @@ void AudioCodecModel::removeAudioCodec(QModelIndex idx) { ...@@ -127,8 +127,10 @@ void AudioCodecModel::removeAudioCodec(QModelIndex idx) {
///Remove everything ///Remove everything
void AudioCodecModel::clear() void AudioCodecModel::clear()
{ {
foreach(AudioCodecData* data2, m_lAudioCodecs) { while(m_lAudioCodecs.size()) {
delete data2; AudioCodecData* d = m_lAudioCodecs[0];
m_lAudioCodecs.removeAt(0);
delete d;
} }
m_lAudioCodecs.clear (); m_lAudioCodecs.clear ();
m_lEnabledCodecs.clear(); m_lEnabledCodecs.clear();
......
...@@ -131,9 +131,11 @@ void CallModel::init() ...@@ -131,9 +131,11 @@ void CallModel::init()
///Destructor ///Destructor
CallModel::~CallModel() CallModel::~CallModel()
{ {
foreach (Call* call, m_sPrivateCallList_call.keys()) const QList<Call*> keys = m_sPrivateCallList_call.keys();
const QList<InternalStruct*> values = m_sPrivateCallList_call.values();
foreach (Call* call, keys )
delete call; delete call;
foreach (InternalStruct* s, m_sPrivateCallList_call.values()) foreach (InternalStruct* s, values )
delete s; delete s;
m_sPrivateCallList_call.clear (); m_sPrivateCallList_call.clear ();
m_sPrivateCallList_callId.clear(); m_sPrivateCallList_callId.clear();
...@@ -337,7 +339,7 @@ void CallModel::removeCall(Call* call, bool noEmit) ...@@ -337,7 +339,7 @@ void CallModel::removeCall(Call* call, bool noEmit)
if (m_sPrivateCallList_call[call] != nullptr) { if (m_sPrivateCallList_call[call] != nullptr) {
m_lInternalModel.removeAll(m_sPrivateCallList_call[call]); m_lInternalModel.removeAll(m_sPrivateCallList_call[call]);
m_sPrivateCallList_call.remove(call); //NOTE Do not free the memory, it can still be used elsewhere or in modelindexes
} }
if (m_sPrivateCallList_callId[m_sPrivateCallList_callId.key(internal)] == internal) { if (m_sPrivateCallList_callId[m_sPrivateCallList_callId.key(internal)] == internal) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment