CandidateReg set_text , set_preedit, set_comment 增加警告#295
Conversation
cand.text , cand.preedit, cand.comment 無法設定時,輸出LOG(WARNING)
| void set_text(T &c, const string &v) { | ||
| if (auto p = dynamic_cast<SimpleCandidate *>(&c)) | ||
| p->set_text(v); | ||
| else if (auto p = (WrapShadow *) dynamic_cast<ShadowCandidate *>(&c)) |
There was a problem hiding this comment.
ShadowCandidate 并不是一种 WrapShadow,所以这个 cast 不对。
There was a problem hiding this comment.
改成 LuaShadowCandidate 呢?
There was a problem hiding this comment.
与名字没有关系。原来的对象是 ShadowCandidate 的实例,并不能安全地转换为 WrapShadow。
There was a problem hiding this comment.
这里有一个巧合,是 WrapShadow 在内存中的布局恰好与 ShadowCandidate 一样了,所以表面上能工作。但实际上是不合法的。
There was a problem hiding this comment.
這的確是我的動機 , 當初是想在 api 中方便操作 ShadowCandidate text ,comment
如果 只能 an to WrapShadow , 那麼就只能 在filter 中
先行置換 Shadow 了
1 在filter 中改 , 這個較易 取出 Phrase 重裝 Shadow or WrapShadow
2 在 onCommit 前 改 candidate text ,但是
沒有方法可以交換 Menu 中的成員 CandidateList
所以提供 Candidate 可以修改 text 較方便的方式
There was a problem hiding this comment.
想到了 直接用 委任 類似 shadow 再上 委任接口 及 text , comment
那麼 就可以委任 shadow phrase Uniquified 了
Signed-off-by: shewer <shewer@gmail.com>
Signed-off-by: shewer <shewer@gmail.com>
…s (#806) Signed-off-by: shewer <shewer@gmail.com>
Signed-off-by: shewer <shewer@gmail.com>
Signed-off-by: shewer <shewer@gmail.com>
|
Signed-off-by: shewer <shewer@gmail.com>
Signed-off-by: shewer <shewer@gmail.com>
cand.text , cand.preedit, cand.comment 無法設定時,輸出LOG(WARNING)