Alexander Petrov schrieb: > Hi > > On 8/7/06, Christian Ehrlicher <[EMAIL PROTECTED]> wrote: >>>> #ifdef WIN32 >>>> info.name = static_cast<const char*>(f.lower()); >>>> #else >>>> info.name = strdup(QFile::encodeName(f)); >>>> #endif >>>> >>>> >>>> Why was this small memleak only fixed for win32? And why isn't the >>> filename encoded on win32? >>> >>> 1. http://doc.trolltech.com/3.3/qfile.html#encodeName : >>> On Windows NT/2000, Unicode file names are supported directly in the >>> file system and this function should be avoided. >>> >> This has imho nothing to do with the problem because we don't use native >> file functions here. Only Qt ones. And if you don't encode a name but later >> decode them for e.g. QFile() it is wrong afterwards... > > what do you mean? > the above sentence about avoiding the QFile::encodeName() is quoted > from Qt's documentation, so it is Trolltech who recommends against > using it. > I would follow their recommendations. > The tt-statement is for things like OpenFile(myFileName,..) and OpenFile(QFile::encodeName(myFileName),...) where both are wrong - you should use OpenFile(myFileName.ucs2(),...) because OpenFile is OpenFileW (per macro)
What happened in sim sources before my changes was:
QString myFileName("test.txt");
#if unix
string fn = QFile::encodeName(myFileName);
#else
string fn = myFileName; // == filename.ascii();
#endif
...
QFile(QFile::decodeName(fn));
which is definitifly wrong.
Christian
signature.asc
Description: OpenPGP digital signature
_______________________________________________ sim-im-main mailing list [email protected] https://mailman.dg.net.ua/listinfo/sim-im-main
