Details
-
Bug
-
Resolution: Invalid
-
P2: Important
-
None
-
5.2.1
-
None
-
Windows7
Description
Here is a peace of code that used to work with 4.7.4 and fails with 5.2.1:
QString folder = QFileDialog::getExistingDirectory( NULL, "", "" );
std::string filename = folder.toStdString() + "/file.txt";
std::fstream file;
file.open( (char*) filename.c_str(), ios_base::out );
assert( file.is_open() );
If you make "folder" point to a folder containing special characters (é, à, ù...), then QString::toStdString fails to return a valid std::string. Qt 4.7.4 used to work because toAScii() was invoked. Qt 5.2.1 fails because it uses toUtf8().
One may workaround the problem by calling toLatin1() rather that toStdString(), but I would say toStdString() is supposed to work smartly as it used to (and moeroevr, I use it in tones of places and don't really want to update them all to migrate my code from 4.7.4 to 5.2.1....).