From efecd2b8d6b7ef9ea32df4d3d7823a65d04e357c Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Tue, 16 May 2017 17:07:06 -0500 Subject: [PATCH] Fixing unicode path issues when loading a Profile() class. Broke when using unicode home directory on Windows. --- include/Profiles.h | 2 ++ src/Profiles.cpp | 20 ++++++++------------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/include/Profiles.h b/include/Profiles.h index 7611f8f1..57bf70da 100644 --- a/include/Profiles.h +++ b/include/Profiles.h @@ -34,6 +34,8 @@ #include #include #include +#include +#include #include #include #include "Exceptions.h" diff --git a/src/Profiles.cpp b/src/Profiles.cpp index e1b93d1a..bfbfeaa0 100644 --- a/src/Profiles.cpp +++ b/src/Profiles.cpp @@ -51,24 +51,19 @@ Profile::Profile(string path) throw(InvalidFile, InvalidJSON) { info.display_ratio.den = 0; info.interlaced_frame = false; - // Read the profile file - ifstream myfile (path.c_str()); - if (myfile.is_open()) + QFile inputFile(path.c_str()); + if (inputFile.open(QIODevice::ReadOnly)) { - // Loop through each line - while (myfile.good()) + QTextStream in(&inputFile); + while (!in.atEnd()) { - // read current line of file - read_file = true; - string line = ""; - getline (myfile, line); + QString line = in.readLine(); if (line.length() <= 0) continue; // Split current line - QString qline(line.c_str()); - QStringList parts = qline.split( "=" ); + QStringList parts = line.split( "=" ); string setting = parts[0].toStdString(); string value = parts[1].toStdString(); int value_int = 0; @@ -117,7 +112,8 @@ Profile::Profile(string path) throw(InvalidFile, InvalidJSON) { info.pixel_format = value_int; } } - myfile.close(); + read_file = true; + inputFile.close(); } }