Skip to content

Commit

Permalink
Merge pull request #1166 from CandyFace/iss940-fixed-locale-delimiter
Browse files Browse the repository at this point in the history
#940 - Fix XML fields corrupting because of locale decimal types.
  • Loading branch information
chchwy authored Feb 4, 2019
2 parents 0c4161a + 469afa4 commit 5674865
Showing 1 changed file with 7 additions and 0 deletions.
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

0 comments on commit 5674865

Please sign in to comment.