[sounds] No sounds file crash fix.

This commit is contained in:
Lev Dragunov 2015-08-21 19:41:39 +03:00 committed by Alex Zolotarev
parent 6437de93ee
commit 3738fe92f4
2 changed files with 9 additions and 1 deletions

View file

@ -39,6 +39,11 @@ GetTextById::GetTextById(TextSource textSouce, string const & localeName)
// @TODO(vbykoianko) Add assert if locale path pathToJson is not valid.
LOG(LDEBUG, ("Trying to open json file at path", pathToJson));
if (!GetPlatform().IsFileExistsByFullPath(pathToJson))
{
LOG(LWARNING, ("Sound instructions test file not exists!"));
return;
}
string jsonBuffer;
ReaderPtr<Reader>(GetPlatform().GetReader(pathToJson)).ReadAsString(jsonBuffer);
InitFromJson(jsonBuffer);

View file

@ -36,7 +36,8 @@ void GetTtsText::SetLocale(string const & locale)
{
m_locale = locale;
m_getCurLang.reset(new platform::GetTextById(platform::TextSource::TtsSound, locale));
ASSERT(m_getCurLang && m_getCurLang->IsValid(), ());
/// @todo Factor out file check from constructor and do not create m_getCurLang object in case of error.
ASSERT(m_getCurLang, ());
}
void GetTtsText::SetLocaleWithJson(string const & jsonBuffer)
@ -47,6 +48,8 @@ void GetTtsText::SetLocaleWithJson(string const & jsonBuffer)
string GetTtsText::operator()(Notification const & notification) const
{
if (!m_getCurLang->IsValid())
return string();
if (notification.m_distanceUnits == 0 && !notification.m_useThenInsteadOfDistance)
return GetTextById(GetDirectionTextId(notification));