diff options
author | krzys-h <krzys_h@interia.pl> | 2014-10-15 21:28:40 +0200 |
---|---|---|
committer | krzys-h <krzys_h@interia.pl> | 2014-10-15 21:28:40 +0200 |
commit | 63b6aa56b01d3764f87eb9f3ddcde68bc98f0e6b (patch) | |
tree | 952111e21404f9edc2b1e1ecb6e39accedfdb2b5 /src/common/profile.cpp | |
parent | 47ea8a1175488564c11e09f71447cb19515c6e6c (diff) | |
download | colobot-63b6aa56b01d3764f87eb9f3ddcde68bc98f0e6b.tar.gz colobot-63b6aa56b01d3764f87eb9f3ddcde68bc98f0e6b.tar.bz2 colobot-63b6aa56b01d3764f87eb9f3ddcde68bc98f0e6b.zip |
Fixed crash when colobot.ini doesn't exist
Diffstat (limited to 'src/common/profile.cpp')
-rw-r--r-- | src/common/profile.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/common/profile.cpp b/src/common/profile.cpp index 2fddd51..c43cd75 100644 --- a/src/common/profile.cpp +++ b/src/common/profile.cpp @@ -59,16 +59,21 @@ bool CProfile::Init() try { std::unique_ptr<std::istream> stream; + bool good = false; if (m_useCurrentDirectory) { - stream = std::unique_ptr<std::istream>(new std::ifstream("./colobot.ini")); + std::ifstream* inputStream = new std::ifstream("./colobot.ini"); + stream = std::unique_ptr<std::istream>(inputStream); + good = inputStream->good(); } else { - stream = std::unique_ptr<std::istream>(new CInputStream("colobot.ini")); + CInputStream* inputStream = new CInputStream("colobot.ini"); + stream = std::unique_ptr<std::istream>(inputStream); + good = inputStream->is_open(); } - if (stream->good()) + if (good) { bp::ini_parser::read_ini(*stream, m_propertyTree); } |