Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Evergreen:11.1
kdepimlibs4
r892407-idmapper-robustness.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File r892407-idmapper-robustness.diff of Package kdepimlibs4
Subject: Add robustness to KRES::IdMapper From: wstephenson@novell.com Bug: bnc#441363 Patch-Upstream: r892407 Index: kresources/tests/idmappertest.cpp =================================================================== --- kresources/tests/idmappertest.cpp (revision 892406) +++ kresources/tests/idmappertest.cpp (revision 892407) @@ -36,6 +36,7 @@ mapper.setRemoteId( "foo", "bar" ); mapper.setRemoteId( "yes", "klar" ); mapper.setRemoteId( "no", "nee" ); + mapper.setRemoteId( QString(), QString() ); QString mapperAsString = "foo\tbar\t\r\nno\tnee\t\r\nyes\tklar\t\r\n"; Index: kresources/idmapper.cpp =================================================================== --- kresources/idmapper.cpp (revision 892406) +++ kresources/idmapper.cpp (revision 892407) @@ -115,8 +115,12 @@ while ( !ts.atEnd() ) { line = ts.readLine( 1024 ); QStringList parts = line.split( "\x02\x02", QString::KeepEmptyParts ); - d->idMap.insert( parts[ 0 ], parts[ 1 ] ); - d->fingerprintMap.insert( parts[ 0 ], parts[ 2 ] ); + // sanity check; the uidmap file could be corrupted and + // QList doesn't like accessing invalid indexes + if ( parts.count() == 3 ) { + d->idMap.insert( parts[ 0 ], parts[ 1 ] ); + d->fingerprintMap.insert( parts[ 0 ], parts[ 2 ] ); + } } file.close(); @@ -157,17 +161,21 @@ void IdMapper::setRemoteId( const QString &localId, const QString &remoteId ) { - d->idMap.insert( localId, remoteId ); + if ( !( localId.isEmpty() || remoteId.isEmpty() ) ) { + d->idMap.insert( localId, remoteId ); + } } void IdMapper::removeRemoteId( const QString &remoteId ) { - QMap<QString, QVariant>::Iterator it; - for ( it = d->idMap.begin(); it != d->idMap.end(); ++it ) { - if ( it.value().toString() == remoteId ) { - d->idMap.remove( it.key() ); - d->fingerprintMap.remove( it.key() ); - return; + if ( !remoteId.isEmpty( ) ) { + QMap<QString, QVariant>::Iterator it; + for ( it = d->idMap.begin(); it != d->idMap.end(); ++it ) { + if ( it.value().toString() == remoteId ) { + d->idMap.remove( it.key() ); + d->fingerprintMap.remove( it.key() ); + return; + } } } } @@ -214,7 +222,9 @@ void IdMapper::setFingerprint( const QString &localId, const QString &fingerprint ) { - d->fingerprintMap.insert( localId, fingerprint ); + if ( !( localId.isEmpty() || fingerprint.isEmpty() ) ) { + d->fingerprintMap.insert( localId, fingerprint ); + } } QString IdMapper::fingerprint( const QString &localId ) const
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor