Skip to content

Commit

Permalink
Consolidate error messages while loading project (#5269)
Browse files Browse the repository at this point in the history
  • Loading branch information
softrabbit authored Jun 4, 2020
1 parent 97680e0 commit a053061
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion include/Song.h
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ private slots:

SaveOptions m_saveOptions;

QStringList m_errors;
QHash<QString, int> m_errors;

PlayModes m_playMode;
PlayPos m_playPos[Mode_Count];
Expand Down
19 changes: 16 additions & 3 deletions src/core/Song.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1421,21 +1421,34 @@ void Song::clearErrors()

void Song::collectError( const QString error )
{
m_errors.append( error );
if (!m_errors.contains(error)) { m_errors[error] = 1; }
else { m_errors[ error ]++; }
}



bool Song::hasErrors()
{
return ( m_errors.length() > 0 );
return !(m_errors.isEmpty());
}



QString Song::errorSummary()
{
QString errors = m_errors.join("\n") + '\n';
QString errors;

auto i = m_errors.constBegin();
while (i != m_errors.constEnd())
{
errors.append( i.key() );
if( i.value() > 1 )
{
errors.append( tr(" (repeated %1 times)").arg( i.value() ) );
}
errors.append("\n");
++i;
}

errors.prepend( "\n\n" );
errors.prepend( tr( "The following errors occurred while loading: " ) );
Expand Down

0 comments on commit a053061

Please sign in to comment.