1
This commit is contained in:
parent
bfde769e98
commit
17166c21d3
@ -22,7 +22,7 @@
|
||||
class EventHandler : public std::enable_shared_from_this<EventHandler>
|
||||
{
|
||||
public:
|
||||
a8::CommonCbProc cb;
|
||||
std::shared_ptr<a8::CommonCbProc> cb;
|
||||
list_head entry;
|
||||
std::shared_ptr<EventHandler> holder;
|
||||
|
||||
@ -497,7 +497,8 @@ std::weak_ptr<EventHandler> Trigger::AddListener(int event_id, a8::CommonCbProc
|
||||
INIT_LIST_HEAD(&itr->second);
|
||||
}
|
||||
auto p = std::make_shared<EventHandler>();
|
||||
p->cb = cb;
|
||||
p->cb = std::make_shared<a8::CommonCbProc>();
|
||||
*p->cb = cb;
|
||||
list_add_tail(&p->entry, &itr->second);
|
||||
p->holder = p;
|
||||
return p;
|
||||
@ -529,7 +530,8 @@ void Trigger::DispatchEvent(int event_id, const std::vector<std::any>& param)
|
||||
if (itr != listeners_hash_.end()) {
|
||||
struct EventHandler *handle = nullptr, *tmp = nullptr;
|
||||
list_for_each_entry_safe(handle, tmp, &itr->second, entry) {
|
||||
handle->cb(param);
|
||||
auto cb = handle->cb;
|
||||
(*cb)(param);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user