summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrzys-h <krzys_h@interia.pl>2014-10-15 21:28:40 +0200
committerkrzys-h <krzys_h@interia.pl>2014-10-15 21:28:40 +0200
commit63b6aa56b01d3764f87eb9f3ddcde68bc98f0e6b (patch)
tree952111e21404f9edc2b1e1ecb6e39accedfdb2b5
parent47ea8a1175488564c11e09f71447cb19515c6e6c (diff)
downloadcolobot-63b6aa56b01d3764f87eb9f3ddcde68bc98f0e6b.tar.gz
colobot-63b6aa56b01d3764f87eb9f3ddcde68bc98f0e6b.tar.bz2
colobot-63b6aa56b01d3764f87eb9f3ddcde68bc98f0e6b.zip
Fixed crash when colobot.ini doesn't exist
-rw-r--r--src/common/profile.cpp11
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);
}