[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Re: [PATCH] Dirwatcher isn't called in KDirLister redirections
From: Michael Brade <brade () kde ! org>
Date: 2004-04-12 22:08:44
Message-ID: 200404130008.44256.brade () kde ! org
[Download RAW message or body]
Hi,
> I was testing KDirLister and I found this problem: when KDirLister is
> redirected (when KDirLister is called with devices:/devcdrommntcdrom, it is
> redirected to /mnt/cdrom), it doesn't set autoupdate to the redirected URL.
Good catch! But I'm sorry, the patch is wrong. The line
dir = new DirItem(newUrl);
even introduces a mem leak...
The base problem is simply that the url of the DirItem objects is not updated
in a redirection at all. And once it is updated the KDirWatch reference needs
to be moved as well; which isn't done in KDirListerCache::renameDir() either.
Both bugs are fixed, please review and test.
Will commit tomorrow if nobody finds any valid objections. ;)
Cheers,
--
Michael Brade; KDE Developer, Student of Computer Science
|-mail: echo brade !#|tr -d "c oh"|s\e\d 's/e/\@/2;s/$/.org/;s/bra/k/2'
°--web: http://www.kde.org/people/michaelb.html
KDE 3: The Next Generation in Desktop Experience
["kdirlister.patch" (text/x-diff)]
Index: kdirlister.cpp
===================================================================
RCS file: /home/kde/kdelibs/kio/kio/kdirlister.cpp,v
retrieving revision 1.174
diff -u -3 -p -r1.174 kdirlister.cpp
--- kdirlister.cpp 18 Mar 2004 20:48:35 -0000 1.174
+++ kdirlister.cpp 12 Apr 2004 22:06:52 -0000
@@ -1,7 +1,7 @@
/* This file is part of the KDE project
Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
2000 Carsten Pfeiffer <pfeiffer@kde.org>
- 2001, 2002 Michael Brade <brade@kde.org>
+ 2001-2004 Michael Brade <brade@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -1036,6 +1036,7 @@ void KDirListerCache::slotRedirection( K
delete dir->rootItem;
dir->rootItem = 0;
dir->lstItems->clear();
+ dir->redirect( newUrl );
itemsInUse.insert( newUrl.url(), dir );
urlsCurrentlyListed.insert( newUrl.url(), listers );
}
@@ -1069,10 +1070,8 @@ void KDirListerCache::renameDir( const K
newDirUrl.addPath( relPath ); // add unchanged relative path
//kdDebug(7004) << "KDirListerCache::renameDir new url=" << newDirUrl.prettyURL() << endl;
- // Update URL in root item and in itemsInUse
- if ( dir->rootItem )
- dir->rootItem->setURL( newDirUrl );
- dir->url = newDirUrl;
+ // Update URL in dir item and in itemsInUse
+ dir->redirect( newDirUrl );
itemsInUse.remove( itu.currentKey() ); // implies ++itu
itemsInUse.insert( newDirUrl.url(-1), dir );
goNext = false; // because of the implied ++itu above
@@ -1380,7 +1379,7 @@ KIO::ListJob *KDirListerCache::jobForUrl
return 0;
}
-void KDirListerCache::killJob( KIO::ListJob *job)
+void KDirListerCache::killJob( KIO::ListJob *job )
{
jobs.remove( job );
job->disconnect( this );
Index: kdirlister_p.h
===================================================================
RCS file: /home/kde/kdelibs/kio/kio/kdirlister_p.h,v
retrieving revision 1.30
diff -u -3 -p -r1.30 kdirlister_p.h
--- kdirlister_p.h 15 Aug 2003 23:40:17 -0000 1.30
+++ kdirlister_p.h 12 Apr 2004 22:07:11 -0000
@@ -59,9 +59,9 @@ public:
lstRemoveItems = 0;
changes = NONE;
-
+
window = 0;
-
+
lstFilters.setAutoDelete( true );
oldFilters.setAutoDelete( true );
}
@@ -97,10 +97,10 @@ public:
KFileItem *rootFileItem;
KFileItemList *lstNewItems, *lstRefreshItems, *lstMimeFilteredItems,
- *lstRemoveItems;
+ *lstRemoveItems;
int changes;
-
+
QWidget *window; // Main window ths lister is associated with
QString nameFilter;
@@ -181,7 +181,7 @@ private slots:
void slotFileDirty( const QString &_file );
void slotFileCreated( const QString &_file );
void slotFileDeleted( const QString &_file );
-
+
void slotFileDirtyDelayed();
void slotEntries( KIO::Job *job, const KIO::UDSEntryList &entries );
@@ -236,21 +236,35 @@ private:
delete lstItems;
}
+ void redirect( const KURL& newUrl )
+ {
+ if ( autoUpdates )
+ {
+ if ( url.isLocalFile() )
+ kdirwatch->removeDir( url.path() );
+
+ if ( newUrl.isLocalFile() )
+ kdirwatch->addDir( newUrl.path() );
+ }
+
+ url = newUrl;
+
+ if ( rootItem )
+ rootItem->setURL( newUrl );
+ }
+
void incAutoUpdate()
{
- if ( url.isLocalFile() && autoUpdates++ == 0 )
+ if ( autoUpdates++ == 0 && url.isLocalFile() )
kdirwatch->addDir( url.path() );
}
void decAutoUpdate()
{
- if ( url.isLocalFile() )
- {
- if ( --autoUpdates == 0 )
- kdirwatch->removeDir( url.path() );
- else if ( autoUpdates < 0 )
- autoUpdates = 0;
- }
+ if ( --autoUpdates == 0 && url.isLocalFile() )
+ kdirwatch->removeDir( url.path() );
+ else if ( autoUpdates < 0 )
+ autoUpdates = 0;
}
// number of KDirListers using autoUpdate for this dir
@@ -293,7 +307,7 @@ private:
// running timers for the delayed update
QDict<QTimer> pendingUpdates;
-
+
static KDirListerCache* s_pSelf;
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic