diff options
-rw-r--r-- | src/ise-stt-mode.cpp | 66 | ||||
-rw-r--r-- | src/ise.cpp | 10 | ||||
-rw-r--r-- | src/ise_lang_table.cpp | 9 |
3 files changed, 46 insertions, 39 deletions
diff --git a/src/ise-stt-mode.cpp b/src/ise-stt-mode.cpp index 50eabd3..cdac22e 100644 --- a/src/ise-stt-mode.cpp +++ b/src/ise-stt-mode.cpp @@ -262,17 +262,10 @@ bool _app_stt_initialize(VoiceData *voice_data) } vd->sttfeedback = new is::stt::SttFeedback(); - if (vd->sttfeedback) { - vd->sttfeedback->SetVoiceData(vd); + vd->sttfeedback->SetVoiceData(vd); - vd->sttmanager = new is::stt::SttManager(*(vd->sttfeedback)); - if (vd->sttmanager) - vd->sttmanager->Prepare(); - else - LOGW("Failed to allocate SttManager"); - } else { - LOGW("Failed to allocate SttFeedback"); - } + vd->sttmanager = new is::stt::SttManager(*(vd->sttfeedback)); + vd->sttmanager->Prepare(); } catch(std::exception &e) { LOGD("%s", e.what()); return false; @@ -304,17 +297,21 @@ static Eina_Bool _idler_cb(void *data) Evas_Object *canvas = elm_object_part_content_get(voicedata->layout_main, "EFFECT_BG"); - is::ui::WInputSttMicEffect *ieffect = new is::ui::WInputSttMicEffect(); - if (ieffect && voicedata->sttmanager) { - ieffect->SetSttHandle(voicedata->sttmanager->GetSttHandle()); - } + try { + is::ui::WInputSttMicEffect *ieffect = new is::ui::WInputSttMicEffect(); + if (voicedata->sttmanager) { + ieffect->SetSttHandle(voicedata->sttmanager->GetSttHandle()); + } - is::ui::MicEffector *effector = new is::ui::MicEffector(canvas, voicedata->layout_main, *ieffect); - voicedata->ieffect = ieffect; - voicedata->effector = effector; + is::ui::MicEffector *effector = new is::ui::MicEffector(canvas, voicedata->layout_main, *ieffect); + voicedata->ieffect = ieffect; + voicedata->effector = effector; - if (ieffect && voicedata->progressbar) { - ieffect->SetProgressBar(voicedata->progressbar); + if (voicedata->progressbar) { + ieffect->SetProgressBar(voicedata->progressbar); + } + } catch (std::bad_alloc &e) { + LOGE("Memory allocation failed"); } elm_access_highlight_set(voicedata->mic_button); @@ -877,26 +874,27 @@ void show_voice_input(Evas_Object *parent, const char *lang, void (*get_string)( destroy_voice(); if (!my_voicedata) { - my_voicedata = new VoiceData; - if (my_voicedata == NULL) { - LOGD("%d::::Heap Overflow, Voice Input cannot be shown!", __LINE__); + try { + my_voicedata = new VoiceData; + } + catch (std::bad_alloc &e) { + LOGE("%d::::Heap Overflow, Voice Input cannot be shown!", __LINE__); return; } - init_voicedata(my_voicedata); } - if (my_voicedata) { - init = init_voice(parent, lang, my_voicedata); - if (init) { - if (my_voicedata->win) { - //ise_stt_start(my_voicedata); - show_voice_window(my_voicedata->win, my_voicedata); - } - } else { - destroy_voice(); - LOGD("%d::::Fail to create Voice window!", __LINE__); - return; + init_voicedata(my_voicedata); + + init = init_voice(parent, lang, my_voicedata); + if (init) { + if (my_voicedata->win) { + //ise_stt_start(my_voicedata); + show_voice_window(my_voicedata->win, my_voicedata); } + } else { + destroy_voice(); + LOGD("%d::::Fail to create Voice window!", __LINE__); + return; } vconf_notify_key_changed(VCONFKEY_ISE_STT_LANGUAGE, _stt_lang_changed_cb, my_voicedata); diff --git a/src/ise.cpp b/src/ise.cpp index 30ca013..8860216 100644 --- a/src/ise.cpp +++ b/src/ise.cpp @@ -524,10 +524,14 @@ static void add_softcandidate_hide_timer(void) static void create_softcandidate(void) { if (!g_candidate) { - g_candidate = CandidateFactory::make_candidate(CANDIDATE_MULTILINE, ime_get_main_window()); - if (g_candidate) { - g_candidate->add_event_listener(&g_candidate_event_listener); + try { + g_candidate = CandidateFactory::make_candidate(CANDIDATE_MULTILINE, ime_get_main_window()); } + catch (std::bad_alloc &e) { + return; + } + + g_candidate->add_event_listener(&g_candidate_event_listener); } } diff --git a/src/ise_lang_table.cpp b/src/ise_lang_table.cpp index 2f772ee..7b1fa53 100644 --- a/src/ise_lang_table.cpp +++ b/src/ise_lang_table.cpp @@ -208,10 +208,15 @@ find_uuid(const std::vector<Keyboard_UUID>& vec_rec, const std::string& name) { static inline char* get_str(std::string str) { int len = str.length(); + char* p = NULL; if (len == 0) return NULL; - char* p = new char[len + 1]; - if (p == NULL) return NULL; + try { + p = new char[len + 1]; + } + catch (std::bad_alloc &e) { + return NULL; + } strncpy(p, str.c_str(), len); p[len] = 0; |