[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: extragear/multimedia/amarok/src/collection/daap
From: Maximilian Kossick <maximilian.kossick () googlemail ! com>
Date: 2009-02-21 14:48:19
Message-ID: 1235227699.671633.5517.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 929526 by mkossick:
be more careful with data read from config files
avoid dangling pointers
M +13 -2 DaapCollection.cpp
M +2 -1 DaapCollection.h
--- trunk/extragear/multimedia/amarok/src/collection/daap/DaapCollection.cpp #929525:929526
@@ -73,6 +73,10 @@
{
debug() << "Adding server " << server;
QStringList current = server.split( ':', QString::KeepEmptyParts );
+ //handle invalid urls gracefully
+ if( current.count() < 2 )
+ continue;
+
QString host = current.first();
quint16 port = current.last().toUShort();
@@ -88,11 +92,18 @@
QString key = serverKey( service.data()->hostName(), service.data()->port() );
if( m_collectionMap.contains( key ) )
{
- DaapCollection* coll = m_collectionMap[ key ];
+ DaapCollection *coll = m_collectionMap[ key ];
if( coll )
+ {
coll->serverOffline(); //collection will be deleted by collectionmanager
+ }
else
+ {
warning() << "collection already null";
+ }
+
+ m_collectionMap.remove( key );
+
}
else
warning() << "removing non-existent service";
@@ -191,7 +202,7 @@
if( m_collectionMap.contains(serverKey( host, port )) ) //same server from multiple interfaces
return;
- DaapCollection *coll = new DaapCollection( host, ip, port );
+ QPointer<DaapCollection> coll( new DaapCollection( host, ip, port ) );
connect( coll, SIGNAL( collectionReady() ), SLOT( slotCollectionReady() ) );
connect( coll, SIGNAL( remove() ), SLOT( slotCollectionDownloadFailed() ) );
m_collectionMap.insert( serverKey( host, port ), coll );
--- trunk/extragear/multimedia/amarok/src/collection/daap/DaapCollection.h #929525:929526
@@ -28,6 +28,7 @@
#include <QMap>
#include <QHash>
#include <QHostInfo>
+#include <QPointer>
#include <QtGlobal>
#include <dnssd/remoteservice.h> //for DNSSD::RemoteService::Ptr
@@ -64,7 +65,7 @@
private:
DNSSD::ServiceBrowser* m_browser;
- QMap<QString, DaapCollection*> m_collectionMap;
+ QMap<QString, QPointer<DaapCollection> > m_collectionMap;
QHash<int, quint16> m_lookupHash;
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic