diff options
author | vng <viktor.govako@gmail.com> | 2015-03-30 19:09:29 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:45:11 +0300 |
commit | 5874e598ea2236305cb4b9a50c0a877f1cbc4a83 (patch) | |
tree | fe840775e998ee8a17e2aec68f67eeea0986d41a /platform | |
parent | f9d0921c64710aad14433b13f91b62c36089ac83 (diff) |
Fixed invalid rect loading. Can cause gray screen on a device.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/settings.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/platform/settings.cpp b/platform/settings.cpp index 1a43b66e3d..dd77ba23ab 100644 --- a/platform/settings.cpp +++ b/platform/settings.cpp @@ -15,6 +15,7 @@ #include "../std/sstream.hpp" #include "../std/iostream.hpp" +#include "../std/cmath.hpp" #define FIRST_LAUNCH_KEY "FirstLaunchOnDate" @@ -117,7 +118,12 @@ namespace Settings istringstream in(s); size_t count = 0; while (in.good() && count < N) - in >> arr[count++]; + { + in >> arr[count]; + if (!std::isfinite(arr[count])) + return false; + ++count; + } return (!in.fail() && count == N); } @@ -141,9 +147,12 @@ namespace Settings if (!impl::FromStringArray(str, val)) return false; - rect = m2::AnyRectD(m2::PointD(val[0], val[1]), - ang::AngleD(val[2]), - m2::RectD(val[3], val[4], val[5], val[6])); + // Will get an assertion in DEBUG and false return in RELEASE. + m2::RectD const r(val[3], val[4], val[5], val[6]); + if (!r.IsValid()) + return false; + + rect = m2::AnyRectD(m2::PointD(val[0], val[1]), ang::AngleD(val[2]), r); return true; } @@ -160,8 +169,9 @@ namespace Settings if (!impl::FromStringArray(str, val)) return false; + // Will get an assertion in DEBUG and false return in RELEASE. rect = m2::RectD(val[0], val[1], val[2], val[3]); - return true; + return rect.IsValid(); } template <> string ToString<bool>(bool const & v) |