Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate error messages while loading project #5269

Merged
merged 2 commits into from
Jun 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1420,21 +1420,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 occured while loading: " ) );
Expand Down