From dbae3b7a5f29d7a53e208566b8a00cf01a9cd70f Mon Sep 17 00:00:00 2001 From: aeoform <2790848120@qq.com> Date: Sat, 16 May 2026 01:40:14 +0800 Subject: [PATCH] fix(linux): correct fcitx5 InputContext::destroyed signal connection syntax MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ic->connect(ic->destroyed, ...) is invalid — InputContext has no two-arg connect overload. Use ic->destroyed.connect(callback) directly, which calls Signal::connect. Also simplified ScopedConnection storage from unique_ptr to direct member (ScopedConnection is move-assignable). Co-Authored-By: Claude Opus 4.7 --- .../scripts/linux-fcitx5-plugin/openless.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/openless-all/scripts/linux-fcitx5-plugin/openless.cpp b/openless-all/scripts/linux-fcitx5-plugin/openless.cpp index cb8ce8e3..3dcbe1f8 100644 --- a/openless-all/scripts/linux-fcitx5-plugin/openless.cpp +++ b/openless-all/scripts/linux-fcitx5-plugin/openless.cpp @@ -96,16 +96,14 @@ public: auto *ic = keyEvent.inputContext(); if (ic != savedIc_) { savedIc_ = ic; - savedIcDestroyedConnection_.reset(); + savedIcDestroyedConnection_ = ScopedConnection(); if (ic) { savedIcDestroyedConnection_ = - std::make_unique( - ic->connect( - ic->destroyed, [this]() { - FCITX_LOGC(openless, Debug) - << "savedIc_ destroyed, clearing"; - savedIc_ = nullptr; - })); + ic->destroyed.connect([this]() { + FCITX_LOGC(openless, Debug) + << "savedIc_ destroyed, clearing"; + savedIc_ = nullptr; + }); } } } @@ -259,9 +257,10 @@ private: uint32_t triggerRawStates_; /// 快捷键按下时保存的输入上下文指针,用于 commitText 在失焦后仍能提交文字。 /// 事件处理线程和 DBus 处理线程都是 fcitx5 主事件循环,无竞态。 - /// 通过 savedIcDestroyedConnection_ 监听 IC 销毁信号自动清空,避免野指针。 + /// 通过 savedIcDestroyedConnection_(连接到 InputContext::destroyed 信号) + /// 监听 IC 销毁时自动清空指针,避免野指针。 InputContext *savedIc_; - std::unique_ptr savedIcDestroyedConnection_; + ScopedConnection savedIcDestroyedConnection_; std::vector>> eventHandlers_; };