开发者

New in 4.7.4: QDir::homePath() gives out empty string

QString path = QDir::homePath();  // <-- "path" is always ""

Is this a new b开发者_C百科ug in 4.7.4? use to work well in 4.7.3

I’m on OSX Lion (4.7.3 worked on Lion well).


The “Clear System Environment” probably cleared the HOME environment variable too.

Basically, QDir::homePath() returns QFile::decodeName(QByteArray(::getenv("HOME"))) almost unchecked. And that's an empty string, if there is no HOME variable.


Hmmm It seems the problem is resolved if I don’t use the “Clear System Environment”. I unchecked it, then re-built and it worked fine. could it be the “SHELL” definitions? I can’t think of anything other than that that’s remotely related to this. I guess something caused Qt to have QT_NO_FSFILEENGINE defined and thus to return an empty string:

// from Qt source file: QDir.cpp

QString QDirPrivate()
{
#ifdef QT_NO_FSFILEENGINE
    return QString();
#else
    return cleanPath(QFSFileEngine::homePath());
#endif
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜