Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
4.5.0
-
None
-
I5663ec0e1ac8f70e0a156357c284696779ecd380
Description
I expected QFileInfo::operator== would only compare filePathes (in a more sophisticated way then a plain string compare).
So I stored QFileInfo-objects in my "projecthandling" and tried to
compare them to fresh created once (so from a filePath-string that came
from somewhere else). When I was testing this in a simple case it seemed
to work fine, but now I have a situation where a "editor" overwrites the
file ... and then in some situation the compare of the old QFileInfo and
the new one returns false.
So I debugged into QFileInfo::operator==, in this false-returning
situation, and it returns false because "size()" is different.
1. I hadn't expected that QFileInfo compare considers the filesize
... so is this really a wanted behavior? (that wrong cashed filesizes
lead to compare "false" ... while filechanges which lead to exact same
filesize are always "true"?)
2. I hadn't expected that it get cached wrong (OK, I already found
"refresh()" and it brought me to an ugly workaround)
3. It doesn't seem to happen everytime (so probably sometime the
"size()" is automatically refreshed? or not correctly captured for the
new QFileInfo?)
1. in small example-code the fileinfo is equal after file changes ...
so, e.g.
QFileInfo f1("my.file");
// ... modifying "my.file"
QFileInfo f2("my.file");
f1 == f2 /// --> will return true!
... as I tried to describe in my first mail, I only get the
"false"-compare in some complex situations
2. comparing the "size()" is not a proper check for file modification
(the same file size could still be a changed file ... and as written in
"1." it seems that the "size()" info is somehow updated in background,
in some cases)
3. if this operator compares more then filePaths ... I would like to get
some suggestion how to properly compare filePaths with Qt (which should
also consider mixed slashes('/','\'), mixed absolute/relative paths and
mixed case on caseinsensitive FileSystems)