Fix kdirlister crash

This resolves Bug 1476
pull/16/head
Timothy Pearson 12 years ago
parent 7217eca586
commit 8188a65884

@ -738,7 +738,7 @@ void KonfUpdate::gotScript(const TQString &_script)
if (script.isEmpty())
{
log() << currentFilename << ": !! Script fails to specifiy filename in line " << m_lineCount << " : '" << m_line << "'" << endl;
log() << currentFilename << ": !! Script fails to specify filename in line " << m_lineCount << " : '" << m_line << "'" << endl;
skip = true;
return;
}

@ -334,12 +334,15 @@ void KDirListerCache::stop( KDirLister *lister )
TQDictIterator< TQPtrList<KDirLister> > it( urlsCurrentlyListed );
TQPtrList<KDirLister> *listers;
int curIndex;
while ( (listers = it.current()) )
{
if ( listers->findRef( lister ) > -1 )
curIndex = listers->findRef( lister );
if ( curIndex > -1 )
{
// lister is listing url
TQString url = it.currentKey();
KDirLister* curLister = listers->at( curIndex );
//kdDebug(7004) << k_funcinfo << " found lister in list - for " << url << endl;
bool ret = listers->removeRef( lister );
@ -360,15 +363,16 @@ void KDirListerCache::stop( KDirLister *lister )
holders->append( lister );
emit lister->canceled( KURL( url ) );
emit lister->canceled( curLister->d->url );
//kdDebug(7004) << k_funcinfo << "remaining list: " << listers->count() << " listers" << endl;
if ( listers->isEmpty() )
{
// kill the job since it isn't used any more
if ( job )
if ( job ) {
killJob( job );
}
urlsCurrentlyListed.remove( url );
}
@ -414,8 +418,9 @@ void KDirListerCache::stop( KDirLister *lister, const KURL& _u )
TDEIO::ListJob *job = jobForUrl( urlStr + ":" + urlReferenceStr );
if ( job )
if ( job ) {
lister->jobDone( job );
}
emit lister->canceled( _url );
@ -1255,8 +1260,9 @@ void KDirListerCache::slotRedirection( TDEIO::Job *j, const KURL& url )
for ( KDirLister *kdl = listers->first(); kdl; kdl = listers->next() )
curListers->append( kdl );
}
else
else {
urlsCurrentlyListed.insert( newUrl.url() + ":" + newUrl.internalReferenceURL(), listers );
}
if ( oldJob ) // kill the old job, be it a list-job or an update-job
killJob( oldJob );
@ -1726,8 +1732,10 @@ TDEIO::ListJob *KDirListerCache::jobForUrl( const TQString& url, TDEIO::ListJob
while ( it != jobs.end() )
{
job = it.key();
if ( joburl( job ).url(-1) == url && job != not_job )
KURL itjoburl = joburl( job );
if ( ((itjoburl.url(-1) + ":" + itjoburl.internalReferenceURL()) == url) && (job != not_job) ) {
return job;
}
++it;
}
return 0;

@ -108,8 +108,9 @@ KFileItem::KFileItem( const KURL &url, const TQString &mimeType, mode_t mode )
m_hidden( Auto ),
d(0)
{
if (m_bMimeTypeKnown)
if (m_bMimeTypeKnown) {
m_pMimeType = KMimeType::mimeType( mimeType );
}
init( false );
}
@ -136,8 +137,9 @@ void KFileItem::init( bool _determineMimeTypeOnDemand )
m_access = TQString::null;
m_size = (TDEIO::filesize_t) -1;
// metaInfo = KFileMetaInfo();
for ( int i = 0; i < NumFlags; i++ )
for ( int i = 0; i < NumFlags; i++ ) {
m_time[i] = (time_t) -1;
}
// determine mode and/or permissions if unknown
if ( m_fileMode == KFileItem::Unknown || m_permissions == KFileItem::Unknown )
@ -160,21 +162,25 @@ void KFileItem::init( bool _determineMimeTypeOnDemand )
if ( S_ISLNK( mode ) )
{
m_bLink = true;
if ( KDE_stat( path.data(), &buf ) == 0 )
if ( KDE_stat( path.data(), &buf ) == 0 ) {
mode = buf.st_mode;
else // link pointing to nowhere (see tdeio/file/file.cc)
}
else { // link pointing to nowhere (see tdeio/file/file.cc)
mode = (S_IFMT-1) | S_IRWXU | S_IRWXG | S_IRWXO;
}
}
// While we're at it, store the times
m_time[ Modification ] = buf.st_mtime;
m_time[ Access ] = buf.st_atime;
if ( m_fileMode == KFileItem::Unknown )
if ( m_fileMode == KFileItem::Unknown ) {
m_fileMode = mode & S_IFMT; // extract file type
if ( m_permissions == KFileItem::Unknown )
}
if ( m_permissions == KFileItem::Unknown ) {
m_permissions = mode & 07777; // extract permissions
}
}
}
}
// determine the mimetype
if (!m_pMimeType && !m_url.isEmpty())

Loading…
Cancel
Save