[Interest] QDir::cdUp looping forever
alexander golks
alex at golks.de
Thu Nov 27 15:54:36 CET 2014
hi,
i am running windows 7, using qt-online 5.3.2.
when executing following code on a network share as working directory, e.g. "//server/data/":
QDir dir=QDir::current();
qDebug()<<"start dir="<<dir;
while(dir.cdUp())
qDebug()<<"up dir="<<dir;
this will print:
start dir= QDir( "//server/data" , nameFilters = { * }, QDir::SortFlags( Name | IgnoreCase ) , QDir::Filters( Dirs|Files|Drives|AllEntries ) )
up dir= QDir( "//server" , nameFilters = { * }, QDir::SortFlags( Name | IgnoreCase ) , QDir::Filters( Dirs|Files|Drives|AllEntries ) )
up dir= QDir( "//server.." , nameFilters = { * }, QDir::SortFlags( Name | IgnoreCase ) , QDir::Filters( Dirs|Files|Drives|AllEntries ) )
up dir= QDir( "//server...." , nameFilters = { * }, QDir::SortFlags( Name | IgnoreCase ) , QDir::Filters( Dirs|Files|Drives|AllEntries ) )
up dir= QDir( "//server......"
and on and on.
the problem seems to be:
bool QDir::cd(const QString &dirName)
//...
if (isRoot())
newPath = d->dirEntry.filePath();
else
newPath = d->dirEntry.filePath() % QLatin1Char('/');
newPath += dirName;
whereas qt 4.8.6 has an additional check there:
//...
if (isRoot()) {
if (dirName == QLatin1String(".."))
return false;
newPath = d->dirEntry.filePath();
} else {
newPath = d->dirEntry.filePath() % QLatin1Char('/');
}
newPath += dirName;
is this a regression, or what?
can't we do just a
//...
newPath = d->dirEntry.filePath() % QLatin1Char('/') + dirName;
and let the rest of code clean and fix the path?
alex
--
/*
* There is an old time toast which is golden for its beauty.
* "When you ascend the hill of prosperity may you not meet a friend."
* -- Mark Twain
*/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20141127/64e53346/attachment.sig>
More information about the Interest
mailing list