diff --git a/src/libtomahawk/DropJob.cpp b/src/libtomahawk/DropJob.cpp index 17f517a2f..4ff08893a 100644 --- a/src/libtomahawk/DropJob.cpp +++ b/src/libtomahawk/DropJob.cpp @@ -263,9 +263,14 @@ bool DropJob::validateLocalFiles(const QString &paths, const QString &suffix) { QStringList filePaths = paths.split( QRegExp( "\\s+" ), QString::SkipEmptyParts ); - for ( QStringList::iterator it = filePaths.begin(); it != filePaths.end(); ++it ) + QStringList::iterator it = filePaths.begin(); + while (it != filePaths.end()) + { if ( !validateLocalFile( *it, suffix ) ) - filePaths.erase( it ); + it = filePaths.erase( it ); + else + ++it; + } return !filePaths.isEmpty(); } @@ -977,7 +982,7 @@ DropJob::removeRemoteSources() foreach ( const Tomahawk::result_ptr& result, item->results() ) { if ( !result->collection().isNull() && !result->collection()->source().isNull() && - !result->collection()->source().isNull() && result->collection()->source()->isLocal() ) + result->collection()->source()->isLocal() ) hasLocalSource = true; } if ( hasLocalSource ) diff --git a/src/libtomahawk/Source.cpp b/src/libtomahawk/Source.cpp index 630456814..aab6e2b85 100644 --- a/src/libtomahawk/Source.cpp +++ b/src/libtomahawk/Source.cpp @@ -235,9 +235,6 @@ Source::friendlyNamesLessThan( const QString& first, const QString& second ) favored.append( QRegExp( "\\b([A-Z][a-z']* ?){2,10}" ) ); //properly capitalized person's name favored.append( QRegExp( "[a-zA-Z ']+" ) ); //kind of person's name - bool matchFirst = false; - bool matchSecond = false; - //We check if the strings match the regexps. The regexps represent friendly name patterns we do //*not* want (penalties) or want (favored), prioritized. If none of the strings match a regexp, //we go to the next regexp. If one of the strings matches, and we're matching penalties, we say @@ -261,8 +258,8 @@ Source::friendlyNamesLessThan( const QString& first, const QString& second ) isPenalty = false; } - matchFirst = rx.exactMatch( first ); - matchSecond = rx.exactMatch( second ); + bool matchFirst = rx.exactMatch( first ); + bool matchSecond = rx.exactMatch( second ); if ( matchFirst == false && matchSecond == false ) continue; diff --git a/src/libtomahawk/accounts/lastfm/LastFmConfig.cpp b/src/libtomahawk/accounts/lastfm/LastFmConfig.cpp index 085ae9b20..e2076b015 100644 --- a/src/libtomahawk/accounts/lastfm/LastFmConfig.cpp +++ b/src/libtomahawk/accounts/lastfm/LastFmConfig.cpp @@ -184,7 +184,7 @@ LastFmConfig::onHistoryLoaded() else finished = true; } - catch( lastfm::ws::ParseError e ) + catch( lastfm::ws::ParseError& e ) { tDebug() << "XmlQuery error:" << e.message(); finished = true; @@ -326,7 +326,7 @@ LastFmConfig::onLovedFinished( QNetworkReply* reply ) emit sizeHintChanged(); } } - catch( lastfm::ws::ParseError e ) + catch( lastfm::ws::ParseError& e ) { m_ui->syncLovedTracks->setText( "Failed" ); m_ui->progressBar->hide(); diff --git a/src/libtomahawk/database/DatabaseCommand_LoadPlaylistEntries.cpp b/src/libtomahawk/database/DatabaseCommand_LoadPlaylistEntries.cpp index 01606b7af..e55b7f6d4 100644 --- a/src/libtomahawk/database/DatabaseCommand_LoadPlaylistEntries.cpp +++ b/src/libtomahawk/database/DatabaseCommand_LoadPlaylistEntries.cpp @@ -119,7 +119,6 @@ DatabaseCommand_LoadPlaylistEntries::generateEntries( DatabaseImpl* dbi ) if ( !query_entries_old.next() ) { return; - Q_ASSERT( false ); } if ( !query_entries_old.value( 0 ).isNull() ) diff --git a/src/libtomahawk/network/Servent.cpp b/src/libtomahawk/network/Servent.cpp index 2be1618a2..3ec755140 100644 --- a/src/libtomahawk/network/Servent.cpp +++ b/src/libtomahawk/network/Servent.cpp @@ -274,7 +274,7 @@ Servent::isValidExternalIP( const QHostAddress& addr ) if ( addr.isInSubnet(QHostAddress::parseSubnet( "224.0.0.0/4" ) ) ) return false; } - else if (addr.protocol() == QAbstractSocket::IPv4Protocol) + else if (addr.protocol() == QAbstractSocket::IPv6Protocol) { // "unspecified address" if ( addr.isInSubnet(QHostAddress::parseSubnet( "::/128" ) ) ) diff --git a/src/libtomahawk/playlist/AlbumModel.cpp b/src/libtomahawk/playlist/AlbumModel.cpp index 9996c7871..a144215de 100644 --- a/src/libtomahawk/playlist/AlbumModel.cpp +++ b/src/libtomahawk/playlist/AlbumModel.cpp @@ -144,10 +144,9 @@ AlbumModel::addAlbums( const QList& albums ) emit beginInsertRows( QModelIndex(), crows.first, crows.second ); - PlayableItem* albumitem; foreach( const album_ptr& album, trimmedAlbums ) { - albumitem = new PlayableItem( album, rootItem() ); + PlayableItem* albumitem = new PlayableItem( album, rootItem() ); albumitem->index = createIndex( rootItem()->children.count() - 1, 0, albumitem ); connect( albumitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) ); @@ -190,10 +189,9 @@ AlbumModel::addArtists( const QList& artists ) emit beginInsertRows( QModelIndex(), crows.first, crows.second ); - PlayableItem* albumitem; foreach ( const artist_ptr& artist, trimmedArtists ) { - albumitem = new PlayableItem( artist, rootItem() ); + PlayableItem* albumitem = new PlayableItem( artist, rootItem() ); albumitem->index = createIndex( rootItem()->children.count() - 1, 0, albumitem ); connect( albumitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) ); @@ -219,10 +217,9 @@ AlbumModel::addQueries( const QList& queries ) emit beginInsertRows( QModelIndex(), crows.first, crows.second ); - PlayableItem* albumitem; foreach ( const query_ptr& query, queries ) { - albumitem = new PlayableItem( query, rootItem() ); + PlayableItem* albumitem = new PlayableItem( query, rootItem() ); albumitem->index = createIndex( rootItem()->children.count() - 1, 0, albumitem ); connect( albumitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) ); diff --git a/src/libtomahawk/playlist/PlayableModel.cpp b/src/libtomahawk/playlist/PlayableModel.cpp index d00ae45c6..5f33b7184 100644 --- a/src/libtomahawk/playlist/PlayableModel.cpp +++ b/src/libtomahawk/playlist/PlayableModel.cpp @@ -269,7 +269,6 @@ PlayableModel::queryData( const query_ptr& query, int column, int role ) const case Age: return TomahawkUtils::ageToString( QDateTime::fromTime_t( query->results().first()->modificationTime() ) ); - break; case Year: if ( query->results().first()->track()->year() != 0 ) @@ -278,11 +277,9 @@ PlayableModel::queryData( const query_ptr& query, int column, int role ) const case Filesize: return TomahawkUtils::filesizeToString( query->results().first()->size() ); - break; case Origin: return query->results().first()->friendlySource(); - break; case Score: { @@ -293,7 +290,6 @@ PlayableModel::queryData( const query_ptr& query, int column, int role ) const score = 0.0; return scoreText( score ); - break; } default: @@ -679,11 +675,10 @@ PlayableModel::insertInternal( const QList< T >& items, int row, const QList< To emit beginInsertRows( parent, crows.first, crows.second ); int i = 0; - PlayableItem* plitem; foreach ( const T& item, items ) { PlayableItem* pItem = itemFromIndex( parent ); - plitem = new PlayableItem( item, pItem, row + i ); + PlayableItem* plitem = new PlayableItem( item, pItem, row + i ); plitem->index = createIndex( row + i, 0, plitem ); if ( plitem->query() ) diff --git a/src/libtomahawk/playlist/PlaylistModel.cpp b/src/libtomahawk/playlist/PlaylistModel.cpp index 6051d2ff8..46b955443 100644 --- a/src/libtomahawk/playlist/PlaylistModel.cpp +++ b/src/libtomahawk/playlist/PlaylistModel.cpp @@ -290,11 +290,10 @@ PlaylistModel::insertEntries( const QList< Tomahawk::plentry_ptr >& entries, int QList< Tomahawk::query_ptr > queries; int i = 0; - PlayableItem* plitem; foreach( const plentry_ptr& entry, entries ) { PlayableItem* pItem = itemFromIndex( parent ); - plitem = new PlayableItem( entry, pItem, row + i ); + PlayableItem* plitem = new PlayableItem( entry, pItem, row + i ); plitem->index = createIndex( row + i, 0, plitem ); if ( logs.count() > i ) diff --git a/src/libtomahawk/playlist/TreeModel.cpp b/src/libtomahawk/playlist/TreeModel.cpp index 45cbdc2b5..47c27ed0d 100644 --- a/src/libtomahawk/playlist/TreeModel.cpp +++ b/src/libtomahawk/playlist/TreeModel.cpp @@ -193,10 +193,9 @@ TreeModel::addAlbums( const QModelIndex& parent, const QListindex = createIndex( parentItem->children.count() - 1, 0, albumitem ); connect( albumitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) ); @@ -283,10 +282,9 @@ TreeModel::onArtistsAdded( const QList& artists ) emit beginInsertRows( QModelIndex(), crows.first, crows.second ); - PlayableItem* artistitem; foreach( const artist_ptr& artist, artists ) { - artistitem = new PlayableItem( artist, rootItem() ); + PlayableItem* artistitem = new PlayableItem( artist, rootItem() ); artistitem->index = createIndex( rootItem()->children.count() - 1, 0, artistitem ); connect( artistitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) ); } @@ -312,10 +310,9 @@ TreeModel::onTracksAdded( const QList& tracks, const QModel emit beginInsertRows( parent, crows.first, crows.second ); - PlayableItem* item = 0; foreach( const query_ptr& query, tracks ) { - item = new PlayableItem( query, parentItem ); + PlayableItem* item = new PlayableItem( query, parentItem ); item->index = createIndex( parentItem->children.count() - 1, 0, item ); connect( item, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) ); diff --git a/src/libtomahawk/resolvers/JSResolver.cpp b/src/libtomahawk/resolvers/JSResolver.cpp index 235bc159c..719133f93 100644 --- a/src/libtomahawk/resolvers/JSResolver.cpp +++ b/src/libtomahawk/resolvers/JSResolver.cpp @@ -557,7 +557,7 @@ JSResolver::parseResultVariantList( const QVariantList& reslist ) continue; unsigned int duration = m.value( "duration", 0 ).toUInt(); - if ( duration <= 0 && m.contains( "durationString" ) ) + if ( duration == 0 && m.contains( "durationString" ) ) { QTime time = QTime::fromString( m.value( "durationString" ).toString(), "hh:mm:ss" ); duration = time.secsTo( QTime( 0, 0 ) ) * -1; @@ -846,12 +846,11 @@ JSResolver::loadCollections() if ( collectionInfo.contains( "iconfile" ) ) { - bool ok = false; QString iconPath = QFileInfo( filePath() ).path() + "/" + collectionInfo.value( "iconfile" ).toString(); QPixmap iconPixmap; - ok = iconPixmap.load( iconPath ); + bool ok = iconPixmap.load( iconPath ); if ( ok && !iconPixmap.isNull() ) sc->setIcon( QIcon( iconPixmap ) ); } diff --git a/src/libtomahawk/resolvers/ScriptEngine.cpp b/src/libtomahawk/resolvers/ScriptEngine.cpp index 933d7b7e1..a347cd729 100644 --- a/src/libtomahawk/resolvers/ScriptEngine.cpp +++ b/src/libtomahawk/resolvers/ScriptEngine.cpp @@ -74,7 +74,6 @@ ScriptEngine::sslErrorHandler( QNetworkReply* qnr, const QList& errli tDebug() << Q_FUNC_INFO; QByteArray digest = errlist.first().certificate().digest(); - int result = -1; if ( !TomahawkSettings::instance()->isSslCertKnown( digest ) ) { @@ -92,7 +91,7 @@ ScriptEngine::sslErrorHandler( QNetworkReply* qnr, const QList& errli question.setStandardButtons( QMessageBox::No ); question.addButton( tr( "Trust certificate" ), QMessageBox::AcceptRole ); - result = question.exec(); + int result = question.exec(); //FIXME: discuss whether we want to store rejects, too (needs settings management to remove the decision?) if ( result == QMessageBox::AcceptRole )