Qt Creator locale issue in release, debug is fine

I’m using the latest version of Qt Creator and have not changed any defaults for the compilation. Everything runs fine in debug mode on Windows 7, 64-bit.

My program runs fine, when I use debug mode and fine as well in release. The only difference is the data that is produced is garbage in the release built. As far as I can follow the problem, it is connected to the difference of the values that are read from a file. Data is saved like 123.43. It seems that the release version expects 123,43 and therefore handles 123.43 incorrectly.

I tried to force a locale:

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
QLocale loc = QLocale::system(); // current locale
loc.setNumberOptions(QLocale::c().numberOptions()); // borrow number options from the "C" locale
QLocale::setDefault(loc); // set as default

ui->setupUi(this);
QCustomPlot *mainPlot = (QCustomPlot*) (ui->mainPlot);
setupMainPlot(mainPlot);
}

But that doesn’t change a thing. Still correct in debug, messed up in release. If it’s not a locale, but a stack problem, I would assume that the program would crash, but everything works fine except the output is full of random data.


Source: windows

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.