diff options
author | Peng Wu <alexepico@gmail.com> | 2022-03-29 10:53:48 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2022-03-29 10:53:48 +0800 |
commit | 65b0919d45ea36b51f89881341f05fadaf60a846 (patch) | |
tree | bc2ef79e12069c3883a6a29a88bcd42385965a6a | |
parent | c851bb9c8ebe013406e8933a13b74ccd2a33fff5 (diff) | |
download | ibus-libpinyin-65b0919d45ea36b51f89881341f05fadaf60a846.tar.gz ibus-libpinyin-65b0919d45ea36b51f89881341f05fadaf60a846.tar.xz ibus-libpinyin-65b0919d45ea36b51f89881341f05fadaf60a846.zip |
Fix some crash
-rw-r--r-- | src/PYPEnglishCandidates.cc | 5 | ||||
-rw-r--r-- | src/PYPPinyinEngine.cc | 3 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/PYPEnglishCandidates.cc b/src/PYPEnglishCandidates.cc index caf2185..8f1a3b2 100644 --- a/src/PYPEnglishCandidates.cc +++ b/src/PYPEnglishCandidates.cc @@ -53,7 +53,6 @@ EnglishCandidates::processCandidates (std::vector<EnhancedCandidate> & candidate enhanced.m_candidate_type = CANDIDATE_ENGLISH; int count = 0; - auto pos = candidates.begin (); if (m_english_database->listWords (prefix, words)) { // sort the words by length and frequency std::stable_sort (words.begin (), words.end (), compare_string_length); @@ -65,9 +64,9 @@ EnglishCandidates::processCandidates (std::vector<EnhancedCandidate> & candidate enhanced.m_candidate_id = count; enhanced.m_display_string = *iter; - candidates.insert (pos, enhanced); + candidates.insert (candidates.begin () + count, enhanced); - ++count; ++pos; + ++count; } return TRUE; diff --git a/src/PYPPinyinEngine.cc b/src/PYPPinyinEngine.cc index d4e439d..a10229b 100644 --- a/src/PYPPinyinEngine.cc +++ b/src/PYPPinyinEngine.cc @@ -380,7 +380,8 @@ PinyinEngine::processKeyEvent (guint keyval, guint keycode, guint modifiers) m_input_mode = MODE_TABLE; m_editors[m_input_mode]->setText (text, text.length ()); Editor * editor = m_editors[m_input_mode].get (); - ((TableEditor *)editor)->updateStateFromInput (); + /* Note: consider to remove the updateStateFromInput method call here. */ + dynamic_cast<TableEditor *>(editor)->updateStateFromInput (); m_editors[m_input_mode]->update (); return TRUE; } |