QDir::separator() vs. "/"

• Jul 4, 2018 - 08:50
Reported version
3.0
Type
Functional
Severity
S4 - Minor
Status
closed
Project

The current code uses QDir::separator() in a few places, but "/" in a lot other places.
While the former might be the correct way for being platform independant, the latter should work too, and in some cases even better.

See https://doc.qt.io/qt-5/qdir.html#separator and http://agateau.com/2015/qdir-separator-considered-harmful/

We should go one or the other way, this wild mixture should not stay. And either way, it should get documented in the developers' handbook's coding style and in mscore3.txt.

My (current ;-)) opinion: go for "/", it is the leaner change and as per the above links better and guaranteed to work on all platforms.

QDir::separator() is used twice in MuseScore::exportParts(), in ResourceManager::downloadLanguage(), and (now) in ResourceManager::downloadExtension() and 3 times in thirdparty/gzip/qzip.cpp, MQZipReader::extractAllFiles().

Maybe we don't want to touch thirdparty/gzip/qzip.cpp and/or get that fixed upstream, but ResourceManager::downloadLanguage() uses MQZipReader (at least MQZipReader::FileInfo()), not sure that matters.


Comments