Add null point check to avoid crash issue 08/170208/2
authorJihoon Kim <jihoon48.kim@samsung.com>
Wed, 14 Feb 2018 07:41:38 +0000 (16:41 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Wed, 14 Feb 2018 08:16:46 +0000 (17:16 +0900)
Change-Id: Id993030b052c838a5483e2aefef824312f560adb
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
src/w-input-stt-voice.cpp

index c784536..a7e9754 100755 (executable)
@@ -329,12 +329,15 @@ static Eina_Bool _update_textblock_timer_cb(void *data)
 
        if (h > 3900){ // to avoid Textblock size overflow (limit : 4000x4000)
                PRINTFUNC(DLOG_ERROR, "Stop STT to avoid text block overflow");
-               if(voicedata->sttmanager->GetCurrent() == STT_STATE_RECORDING || voicedata->sttmanager->GetCurrent() == STT_STATE_PROCESSING) {
-                       PRINTFUNC(DLOG_DEBUG, "STT_STATE_RECORDING or STT_STATE_PROCESSING\n");
-                       try{
-                               voicedata->sttmanager->Cancel();
-                       }catch(is::stt::SttException &e){
-                               PRINTFUNC(DLOG_ERROR, "reason : %s", e.what());
+               if (voicedata->sttmanager) {
+                       if (voicedata->sttmanager->GetCurrent() == STT_STATE_RECORDING ||
+                                       voicedata->sttmanager->GetCurrent() == STT_STATE_PROCESSING) {
+                               PRINTFUNC(DLOG_DEBUG, "STT_STATE_RECORDING or STT_STATE_PROCESSING\n");
+                               try{
+                                       voicedata->sttmanager->Cancel();
+                               }catch(is::stt::SttException &e){
+                                       PRINTFUNC(DLOG_ERROR, "reason : %s", e.what());
+                               }
                        }
                }
        }
@@ -541,14 +544,15 @@ static Eina_Bool _idler_cb(void *data)
 
        is::ui::WInputSttMicEffect *ieffect = new is::ui::WInputSttMicEffect();
        if (ieffect) {
-               ieffect->SetSttHandle(voicedata->sttmanager->GetSttHandle());
+               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;
 
-               ieffect->SetProgressBar(voicedata->progressbar);
-               ieffect->SetSttHandle(voicedata->sttmanager->GetSttHandle());
+               if (voicedata->progressbar)
+                       ieffect->SetProgressBar(voicedata->progressbar);
        }
 
        voicedata->mo->Update();
@@ -767,7 +771,8 @@ static Eina_Bool _start_timer_cb(void* data)
 
                try {
                        voicedata->state = STT_STATE_VAL_PREPARE_LISTENING;
-                       voicedata->sttmanager->Start();
+                       if (voicedata->sttmanager)
+                               voicedata->sttmanager->Start();
                }
                catch (is::stt::SttException &e) {
                        PRINTFUNC(DLOG_ERROR, "%s", e.what());
@@ -856,7 +861,7 @@ void on_initial_anim_press_cb(void *data, Evas_Object *obj, const char *emission
        PRINTFUNC(NO_PRINT, "");
 
        VoiceData *vd = (VoiceData *)data;
-       if (vd == NULL)
+       if (vd == NULL || vd->sttmanager == NULL)
                return;
 
        int tempVal = vd->sttmanager->GetCurrent();
@@ -1407,7 +1412,8 @@ void _stt_lang_changed_cb(keynode_t *key, void* data)
 
        VoiceData *vd = (VoiceData *) data;
        get_stt_default_language(vd);
-       vd->sttmanager->SetLanguage(std::string(vd->kbd_lang));
+       if (vd->sttmanager)
+               vd->sttmanager->SetLanguage(std::string(vd->kbd_lang));
        vd->mo->Update();
 
        return;
@@ -1564,11 +1570,13 @@ static void _stt_entry_clicked_cb(void *data, Evas_Object * obj, void *event_inf
 
        if (str && strlen(str) > 0) {
                try {
-                       if (voicedata->sttmanager->GetCurrent() == STT_STATE_RECORDING ||
-                               voicedata->sttmanager->GetCurrent() == STT_STATE_PROCESSING) {
-                               voicedata->sttmanager->Cancel();
-                               PRINTFUNC(DLOG_DEBUG, "stt entry clicked callback during STT recording and processing");
-                               //return;
+                       if (voicedata->sttmanager) {
+                               if (voicedata->sttmanager->GetCurrent() == STT_STATE_RECORDING ||
+                                       voicedata->sttmanager->GetCurrent() == STT_STATE_PROCESSING) {
+                                       voicedata->sttmanager->Cancel();
+                                       PRINTFUNC(DLOG_DEBUG, "stt entry clicked callback during STT recording and processing");
+                                       //return;
+                               }
                        }
                }
                catch(is::stt::SttException &e) {