Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何防止从 GSignal 中的第一个信号处理程序回调调用进一步的信号处理程序?
例如,我为同一个信号“mysignal”注册了三个函数 - func1、func2 和 func3。如果先调用 func1,如何防止 func2 和 func3 从 func1 调用?
这不应该成为永久性的。它应该是运行时的。即 func1 可以根据它得到的输入参数来决定 func2 和 func3 是否可以得到回调。
g_signal_stop_emission_by_name() 和 g_signal_stop_emission() 解决了这个问题。
从 func1 调用 g_signal_stop_emission_by_name() 可防止进一步传播到 func2 和 func3。