From b932c159c4ab34d4d740552ccedd27f28ffad2c4 Mon Sep 17 00:00:00 2001 From: shun-iwasawa Date: Aug 10 2018 07:00:11 +0000 Subject: fix input field crash (#2223) --- diff --git a/toonz/sources/common/tunit/tunit.cpp b/toonz/sources/common/tunit/tunit.cpp index 6609619..4cde0ec 100644 --- a/toonz/sources/common/tunit/tunit.cpp +++ b/toonz/sources/common/tunit/tunit.cpp @@ -482,7 +482,16 @@ bool TMeasuredValue::setValue(std::wstring s, int *pErr) { } } if (i > j) { - value = std::stod(s.substr(j, i - j)); + try { + value = std::stod(s.substr(j, i - j)); + } + // handle exceptions + catch (const std::invalid_argument &e) { + return false; + } catch (const std::out_of_range &e) { + return false; + } + valueFlag = true; // skip blanks i = s.find_first_not_of(::to_wstring(" \t"), i);