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.
This commit is contained in:
Michael Gregorius
2017-07-27 19:16:05 +02:00
parent 017fb4b089
commit 1f257f8125
2 changed files with 8 additions and 8 deletions

View File

@@ -67,7 +67,7 @@ public:
void clearErrors();
void collectError( const QString error );
bool hasErrors();
QString* errorSummary();
QString errorSummary();
class PlayPos : public MidiTime
{

View File

@@ -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;
}