Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#940 - Fix XML fields corrupting because of locale decimal types. #1166

Merged
merged 1 commit into from
Feb 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions core_lib/src/structure/filemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ GNU General Public License for more details.

#include "filemanager.h"

#include <clocale>
#include <ctime>
#include <QDir>
#include "pencildef.h"
Expand Down Expand Up @@ -207,6 +208,11 @@ bool FileManager::isOldForamt(const QString& fileName) const

Status FileManager::save(Object* object, QString sFileName)
{
// It's important that we save the file as En_US to avoid decimals being changed.
// issue: #940

std::setlocale(LC_NUMERIC, "En_US");

DebugDetails dd;
dd << "FileManager::save";
dd << ("sFileName = " + sFileName);
Expand Down Expand Up @@ -333,6 +339,7 @@ Status FileManager::save(Object* object, QString sFileName)

// -------- save main XML file -----------
QFile file(sMainXMLFile);
std::setlocale(LC_ALL, "");
if (!file.open(QFile::WriteOnly | QFile::Text))
{
return Status(Status::ERROR_FILE_CANNOT_OPEN, dd);
Expand Down