From 1f257f81258cc99f6b89333709e452d4d3b3b2a9 Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Thu, 27 Jul 2017 19:16:05 +0200 Subject: [PATCH] Fix another memory leak by returning the error messages on the stack Change Song::errorSummary() to return the string with the error messages on the stack to remove another memory leak. --- include/Song.h | 2 +- src/core/Song.cpp | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/Song.h b/include/Song.h index bd1215883..9c9d0304c 100644 --- a/include/Song.h +++ b/include/Song.h @@ -67,7 +67,7 @@ public: void clearErrors(); void collectError( const QString error ); bool hasErrors(); - QString* errorSummary(); + QString errorSummary(); class PlayPos : public MidiTime { diff --git a/src/core/Song.cpp b/src/core/Song.cpp index 0efe7b5bb..97ebc2f17 100644 --- a/src/core/Song.cpp +++ b/src/core/Song.cpp @@ -1128,12 +1128,12 @@ void Song::loadProject( const QString & fileName ) { if ( gui ) { - QMessageBox::warning( NULL, tr("LMMS Error report"), *errorSummary(), + QMessageBox::warning( NULL, tr("LMMS Error report"), errorSummary(), QMessageBox::Ok ); } else { - QTextStream(stderr) << *Engine::getSong()->errorSummary() << endl; + QTextStream(stderr) << Engine::getSong()->errorSummary() << endl; } } @@ -1524,17 +1524,17 @@ bool Song::hasErrors() -QString* Song::errorSummary() +QString Song::errorSummary() { - QString* errors = new QString(); + QString errors; for ( int i = 0 ; i < m_errors.length() ; i++ ) { - errors->append( m_errors.value( i ) + "\n" ); + errors.append( m_errors.value( i ) + "\n" ); } - errors->prepend( "\n\n" ); - errors->prepend( tr( "The following errors occured while loading: " ) ); + errors.prepend( "\n\n" ); + errors.prepend( tr( "The following errors occured while loading: " ) ); return errors; }