SVN commit 600835 by dfaure: Factor out the code that determines the id for a given device. Still can't believe that the unit tests pass - the code doesn't actually seem to be called :/ M +9 -2 trashimpl.cpp --- trunk/KDE/kdebase/runtime/kioslave/trash/trashimpl.cpp #600834:600835 @@ -699,6 +699,13 @@ // which will be done by the job soon after this. } +static int idForDevice(Solid::Device& device) +{ + const Solid::Volume* volume = device.as(); + kDebug() << "major=" << volume->major() << " minor=" << volume->minor() << endl; + return volume->major()*1000 + volume->minor(); +} + int TrashImpl::findTrashDirectory( const QString& origPath ) { kDebug() << k_funcinfo << origPath << endl; @@ -736,7 +743,7 @@ Solid::Device device = lst[0]; // new trash dir found, register it - id = device.as()->major()*1000+device.as()->minor(); + id = idForDevice( device ); m_trashDirectories.insert( id, trashDir ); kDebug() << k_funcinfo << "found " << trashDir << " gave it id " << id << endl; if ( !mountPoint.endsWith( "/" ) ) @@ -758,7 +765,7 @@ int trashId = idForTrashDirectory( trashDir ); if ( trashId == -1 ) { // new trash dir found, register it - trashId = (*it).as()->major()*1000+(*it).as()->minor(); + trashId = idForDevice( *it ); m_trashDirectories.insert( trashId, trashDir ); kDebug() << k_funcinfo << "found " << trashDir << " gave it id " << trashId << endl; if ( !topdir.endsWith( "/" ) )