KDE/kdevelop/plugins
Andreas Pakulat
apaku at gmx.de
Fri Jan 30 18:51:23 UTC 2009
SVN commit 918782 by apaku:
Fix startsWith checks by replacing with KUrl::isRelativeUrl.
@kdevelop team: Repeat after me: I will _not_ use startsWith to check for absolute paths. I will _always_ use QFileInfo::isAbsolute or KUrl::isRelativeUrl (the latter is much faster if one doesn't have a QFileInfo object already).
CCMAIL:kdevelop-devel at kdevelop.org
M +6 -6 languages/cpp/includepathresolver.cpp
M +1 -1 managers/cmake/cmakemanager.cpp
--- trunk/KDE/kdevelop/plugins/languages/cpp/includepathresolver.cpp #918781:918782
@@ -286,7 +286,7 @@
//Make the working-directory absolute
QString workingDirectory = _workingDirectory;
- if( KUrl(workingDirectory).isRelative() ) {
+ if( KUrl::isRelativeUrl(workingDirectory) ) {
KUrl u( QDir::currentPath() );
u.addPath( workingDirectory );
workingDirectory = u.path();
@@ -337,7 +337,7 @@
QFileInfo fi( file );
QString absoluteFile = file;
- if( !file.startsWith('/') )
+ if( KUrl::isRelativeUrl( file ) )
absoluteFile = workingDirectory + '/' + file;
KUrl u( absoluteFile );
u.cleanPath();
@@ -350,7 +350,7 @@
targetName = file.left( dot );
QString wd = dir.path();
- if( !wd.startsWith('/') ) {
+ if( KUrl::isRelativeUrl( wd ) ) {
wd = QDir::currentPath() + '/' + wd;
KUrl u( wd );
u.cleanPath();
@@ -491,7 +491,7 @@
int cdIndex = prefix.lastIndexOf( "cd ");
if( cdIndex != -1 ) {
newWorkingDirectory = prefix.right( prefix.length() - 3 - cdIndex ).trimmed();
- if( !newWorkingDirectory.startsWith('/') )
+ if( KUrl::isRelativeUrl( newWorkingDirectory ) )
newWorkingDirectory = workingDirectory + '/' + newWorkingDirectory;
KUrl u( newWorkingDirectory );
u.cleanPath();
@@ -506,7 +506,7 @@
///Looks like valid parameters
///Make the file-name absolute, so it can be referenced from any directory
QString absoluteFile = file;
- if( !absoluteFile.startsWith('/') )
+ if( KUrl::isRelativeUrl( absoluteFile ) )
absoluteFile = workingDirectory + '/' + file;
KUrl u( absoluteFile );
u.cleanPath();
@@ -564,7 +564,7 @@
path = path.mid( 1, path.length() - 2 );
}
}
- if( !path.startsWith('/') )
+ if( KUrl::isRelativeUrl( path ) )
path = workingDirectory + '/' + path;
KUrl u( path );
--- trunk/KDE/kdevelop/plugins/managers/cmake/cmakemanager.cpp #918781:918782
@@ -549,7 +549,7 @@
foreach(const QString& s, v.includeDirectories())
{
QString dir(s);
- if(!s.startsWith('/') && !s.startsWith("#["))
+ if(KUrl::isRelativeUrl( s ) && !s.startsWith("#["))
{
KUrl path=folder->url();
path.addPath(s);
More information about the KDevelop-devel
mailing list