[Qt-interest] QFileInfo returning wrong value in != operator

Scott Aron Bloom Scott.Bloom at onshorecs.com
Tue Aug 16 04:03:29 CEST 2011


I have used it with success, except I check for exists.. and if it doesn’t, I just compare the absolute paths directly

Which would fail in the situation where there are .. and . in the path
Scott


-----Original Message-----
From: Jason H [mailto:scorp1us at yahoo.com] 
Sent: Monday, August 15, 2011 2:02 PM
To: Scott Aron Bloom; Eric Clark; qt-interest at trolltech.com
Subject: Re: [Qt-interest] QFileInfo returning wrong value in != operator

Should probably use a Null string and isNull() instead of isEmpty().

You want a relational database-style null, where a null is not equal to all other nulls. It's probably too late to change canonicalPath to return a isNull()able null string, comparing first the nulls, then looking at string contents. I wonder how the self-tests fare...

But in other news, I think we have a situation where a non-existent file is the same as all other non-existent files... Which does kind-of make sense.

But it seems as if QFileInfo::operator== () is pretty broken anyway.

________________________________
From: Scott Aron Bloom <Scott.Bloom at onshorecs.com>
To: Eric Clark <eclark at ara.com>; qt-interest at trolltech.com
Sent: Monday, August 15, 2011 4:43 PM
Subject: Re: [Qt-interest] QFileInfo returning wrong value in != operator


I believe there is a bug on this, (or there was that I filed years ago)

It stems from the fact that operator == (and !=) use (or used to) canonicalPath, which returns empty string if the file does not exist

My bug suggeste it be documented that the results are unknown if the files don’t exist

Scott

From:qt-interest-bounces+scott.bloom=onshorecs.com at qt.nokia.com [mailto:qt-interest-bounces+scott.bloom=onshorecs.com at qt.nokia.com] On Behalf Of Eric Clark
Sent: Monday, August 15, 2011 12:09 PM
To: Qt Interest (qt-interest at trolltech.com)
Subject: [Qt-interest] QFileInfo returning wrong value in != operator

Hello All,

I am currently using Qt 4.7.1 and I am running into a problem with QFileInfo. I have two instances of QFileInfo and they both point to different files. However, the == operator keeps saying they are the same. Here is the exact paths of the two files:

1.       C:/Users/eclark/EndgameFramework/FourStoryDemo.db
2.       C:/Users/eclark/EndgameFramework/test.db

The two files are clearly different. However, QFileInfo keeps saying they are the same. The only thing I could see that may be a problem is the fact that the files do not exist yet. Does the == operator check for existence? Does anyone know why this would be happening?

Thanks in Advance!
Eric
_______________________________________________
Qt-interest mailing list
Qt-interest at qt.nokia.com
http://lists.qt.nokia.com/mailman/listinfo/qt-interest         


More information about the Qt-interest-old mailing list