diff options
author | Peng Wu <alexepico@gmail.com> | 2014-07-17 13:48:26 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2014-07-17 13:48:26 +0800 |
commit | 3310166780a55b13123388f6632b40bce5464c1c (patch) | |
tree | 538e016f9b53ebd10531c2b57601e71fc89fb8bc | |
parent | 96e0fa602035fc9d634534979aeec4a127ea2f32 (diff) | |
download | ibus-libzhuyin-3310166780a55b13123388f6632b40bce5464c1c.tar.gz ibus-libzhuyin-3310166780a55b13123388f6632b40bce5464c1c.tar.xz ibus-libzhuyin-3310166780a55b13123388f6632b40bce5464c1c.zip |
fixes crashes
-rw-r--r-- | src/ZYZPhoneticEditor.cc | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/ZYZPhoneticEditor.cc b/src/ZYZPhoneticEditor.cc index e98f26c..55eefa3 100644 --- a/src/ZYZPhoneticEditor.cc +++ b/src/ZYZPhoneticEditor.cc @@ -558,7 +558,7 @@ PhoneticEditor::moveCursorLeft (void) (instance, key_rest, &begin, NULL); /* align to the begin of chewing key. */ - m_cursor = start_pos + begin; + m_cursor = m_cursor - (cursor + 1 - begin); update (); return TRUE; } @@ -632,12 +632,12 @@ PhoneticEditor::moveCursorRight (void) if (cursor < parsed_len) { guint16 offset = 0; zhuyin_get_zhuyin_key_rest_offset (instance, cursor, &offset); + offset ++; guint len = 0; zhuyin_get_n_zhuyin (instance, &len); - if (offset < len) { - offset ++; + if (offset < len) { /* move to the begin of next syllable. */ ChewingKeyRest * key_rest = NULL; zhuyin_get_zhuyin_key_rest (instance, offset, &key_rest); @@ -647,12 +647,13 @@ PhoneticEditor::moveCursorRight (void) (instance, key_rest, &begin, NULL); /* align to the begin of chewing key. */ - m_cursor = start_pos + begin; + m_cursor = m_cursor + (begin - cursor); update (); return TRUE; } else { + assert (offset == len); /* align to the end of parsed phonetic section. */ - m_cursor = start_pos + parsed_len; + m_cursor = m_cursor + (parsed_len - cursor); update (); return TRUE; } |