From 7217eca58605fb57b4dd0ffcd7ca4445681ce619 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Fri, 19 Apr 2013 15:47:26 -0500 Subject: Fix KDirLister failure to emit events for all watchers of a given path Fix KURL comparison --- tdeio/tdeio/kdirlister.cpp | 20 +++++++++++--------- tdeio/tdeio/kdirwatch.cpp | 24 ++++++++++++++++++------ 2 files changed, 29 insertions(+), 15 deletions(-) (limited to 'tdeio') diff --git a/tdeio/tdeio/kdirlister.cpp b/tdeio/tdeio/kdirlister.cpp index 8df6755f1..91f025013 100644 --- a/tdeio/tdeio/kdirlister.cpp +++ b/tdeio/tdeio/kdirlister.cpp @@ -274,7 +274,7 @@ bool KDirListerCache::listDir( KDirLister *lister, const KURL& _u, urlsCurrentlyListed[urlStr + ":" + urlReferenceStr]->append( lister ); - TDEIO::ListJob *job = jobForUrl( urlStr ); + TDEIO::ListJob *job = jobForUrl( urlStr + ":" + urlReferenceStr ); Q_ASSERT( job ); lister->jobStarted( job ); @@ -282,8 +282,9 @@ bool KDirListerCache::listDir( KDirLister *lister, const KURL& _u, Q_ASSERT( itemU ); - if ( !lister->d->rootFileItem && lister->d->url == _url ) + if ( !lister->d->rootFileItem && lister->d->url == _url ) { lister->d->rootFileItem = itemU->rootItem; + } lister->addNewItems( *(itemU->lstItems) ); lister->emitItems(); @@ -343,10 +344,11 @@ void KDirListerCache::stop( KDirLister *lister ) //kdDebug(7004) << k_funcinfo << " found lister in list - for " << url << endl; bool ret = listers->removeRef( lister ); Q_ASSERT( ret ); - + TDEIO::ListJob *job = jobForUrl( url ); - if ( job ) + if ( job ) { lister->jobDone( job ); + } // move lister to urlsCurrentlyHeld TQPtrList *holders = urlsCurrentlyHeld[url]; @@ -411,7 +413,7 @@ void KDirListerCache::stop( KDirLister *lister, const KURL& _u ) holders->append( lister ); - TDEIO::ListJob *job = jobForUrl( urlStr ); + TDEIO::ListJob *job = jobForUrl( urlStr + ":" + urlReferenceStr ); if ( job ) lister->jobDone( job ); @@ -498,7 +500,7 @@ void KDirListerCache::forgetDirs( KDirLister *lister, const KURL& _url, bool not itemsInUse.remove( urlStr + ":" + urlReferenceStr ); // this job is a running update - TDEIO::ListJob *job = jobForUrl( urlStr ); + TDEIO::ListJob *job = jobForUrl( urlStr + ":" + urlReferenceStr ); if ( job ) { lister->jobDone( job ); @@ -582,7 +584,7 @@ void KDirListerCache::updateDirectory( const KURL& _dir ) // restart the job for _dir if it is running already bool killed = false; TQWidget *window = 0; - TDEIO::ListJob *job = jobForUrl( urlStr ); + TDEIO::ListJob *job = jobForUrl( urlStr + ":" + urlReferenceStr ); if ( job ) { window = job->window(); @@ -1230,7 +1232,7 @@ void KDirListerCache::slotRedirection( TDEIO::Job *j, const KURL& url ) // get the job if one's running for newUrl already (can be a list-job or an update-job), but // do not return this 'job', which would happen because of the use of redirectionURL() - TDEIO::ListJob *oldJob = jobForUrl( newUrl.url(), job ); + TDEIO::ListJob *oldJob = jobForUrl( newUrl.url() + ":" + newUrl.internalReferenceURL(), job ); // listers of newUrl with oldJob: forget about the oldJob and use the already running one // which will be converted to an updateJob @@ -1445,7 +1447,7 @@ void KDirListerCache::emitRedirections( const KURL &oldUrl, const KURL &url ) TQString oldReferenceUrlStr = oldUrl.internalReferenceURL(); TQString urlReferenceStr = url.internalReferenceURL(); - TDEIO::ListJob *job = jobForUrl( oldUrlStr ); + TDEIO::ListJob *job = jobForUrl( oldUrlStr + ":" + oldReferenceUrlStr ); if ( job ) killJob( job ); diff --git a/tdeio/tdeio/kdirwatch.cpp b/tdeio/tdeio/kdirwatch.cpp index da1f61540..be55c7ea5 100644 --- a/tdeio/tdeio/kdirwatch.cpp +++ b/tdeio/tdeio/kdirwatch.cpp @@ -780,8 +780,9 @@ void KDirWatchPrivate::addEntry(KDirWatch* instance, const KURL& _path, if (path.startsWith("/dev/") || (path == "/dev")) return; // Don't even go there. - if ( path.length() > 1 && path.right(1) == "/" ) + if ( path.length() > 1 && path.right(1) == "/" ) { path.truncate( path.length() - 1 ); + } EntryMap::Iterator it = m_mapEntries.find( _path ); if ( it != m_mapEntries.end() ) @@ -885,8 +886,9 @@ void KDirWatchPrivate::addEntry(KDirWatch* instance, const KURL& _path, e->m_mode = UnknownMode; e->msecLeft = 0; - if ( isNoisyFile( tpath ) ) + if ( isNoisyFile( tpath ) ) { return; + } #ifdef HAVE_FAM if (useFAM(e)) return; @@ -1324,17 +1326,20 @@ void KDirWatchPrivate::slotRescan() { // mark all as dirty it = m_mapEntries.begin(); - for( ; it != m_mapEntries.end(); ++it ) + for( ; it != m_mapEntries.end(); ++it ) { (*it).dirty = true; + } rescan_all = false; } else { // progate dirty flag to dependant entries (e.g. file watches) it = m_mapEntries.begin(); - for( ; it != m_mapEntries.end(); ++it ) - if (((*it).m_mode == INotifyMode || (*it).m_mode == DNotifyMode) && (*it).dirty ) + for( ; it != m_mapEntries.end(); ++it ) { + if (((*it).m_mode == INotifyMode || (*it).m_mode == DNotifyMode) && (*it).dirty ) { (*it).propagate_dirty(); + } + } } it = m_mapEntries.begin(); @@ -1381,7 +1386,14 @@ void KDirWatchPrivate::slotRescan() #endif if ( ev != NoChange ) { - emitEvent( &(*it), ev); + // Emit events for any entries with the same path as the changed entry + EntryMap::Iterator it2; + it2 = m_mapEntries.begin(); + for( ; it2 != m_mapEntries.end(); ++it2 ) { + if ((*it).path.url() == (*it2).path.url()) { + emitEvent( &(*it2), ev); + } + } } } -- cgit v1.2.1