Summary: | non existing files remain in recent-files list | ||
---|---|---|---|
Product: | [Frameworks and Libraries] kdelibs | Reporter: | allabos |
Component: | general | Assignee: | Stephan Kulow <coolo> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | bradh |
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Compiled Sources | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: |
Description
allabos
2001-06-22 20:52:46 UTC
Hi I have a reference to a file in my "Window" menu on Kdevelop (1.4.1 on KDE 2.1.1) and the file is no longer there. Since it has the same filename but different location to a file that I am using I ocasionally click on it to be told the file is not there. Surely better to remove the menu entry when this happens? Ta Dave The second reporter identified the problem in KDevelop, so this isn't strictly a KOffice problem, but a broader KDE issue. Maybe it would be possible to file off some kind of minimal KIO:stat() per URL inside KRecentFilesAction::loadEntries(), and delete things from the list if the stat() says it doesn't exist. That would at least deal with the most common case. I think most people would be willing to tolerate the system not realising that they had deleted a file if it was during that session. The code is pretty trivial: The svn diff: Index: kactionclasses.cpp =================================================================== --- kactionclasses.cpp (revisiĆ³n: 409943) +++ kactionclasses.cpp (copia de trabajo) @@ -34,6 +34,7 @@ #include <qobjectlist.h> #include <qwhatsthis.h> #include <qtimer.h> +#include <qfile.h> #include <dcopclient.h> #include <dcopref.h> @@ -1119,7 +1120,7 @@ QString value; QString oldGroup; QStringList lst; - + oldGroup = config->group(); if (groupname.isEmpty()) @@ -1132,8 +1133,12 @@ key = QString( "File%1" ).arg( i ); value = config->readPathEntry( key ); - if (!value.isNull()) + if (!value.isNull()) + { + KURL addr(value); + if( !addr.isLocalFile() || QFile(addr.path()).exists()) lst.append( value ); + } } I've tested it and works ok. SVN commit 502014 by braxton: Don't restore files to recent files list that don't exist anymore. Same for KURLComboBox. based on a patch by Jordi Polo <mumismo@wanadoo.es> BUG: 27581 M +6 -0 kdeui/kactionclasses.cpp M +6 -0 kio/kfile/kurlcombobox.cpp --- branches/KDE/3.5/kdelibs/kdeui/kactionclasses.cpp #502013:502014 @@ -34,6 +34,7 @@ #include <qobjectlist.h> #include <qwhatsthis.h> #include <qtimer.h> +#include <qfile.h> #include <dcopclient.h> #include <dcopref.h> @@ -1187,6 +1188,11 @@ key = QString( "File%1" ).arg( i ); value = config->readPathEntry( key ); url = KURL::fromPathOrURL( value ); + + // Don't restore if file doesn't exist anymore + if (url.isLocalFile() && !QFile(url.path()).exists()) + continue; + nameKey = QString( "Name%1" ).arg( i ); nameValue = config->readPathEntry( nameKey, url.fileName() ); title = nameValue + " [" + value + "]"; --- branches/KDE/3.5/kdelibs/kio/kfile/kurlcombobox.cpp #502013:502014 @@ -180,6 +180,12 @@ } u = KURL::fromPathOrURL( *it ); + // Don't restore if file doesn't exist anymore + if (u.isLocalFile() && !QFile(u.path()).exists()) { + ++it; + continue; + } + item = new KURLComboItem; item->url = u; item->pixmap = getPixmap( u ); |