From: Mikko Rasa Date: Sat, 22 Oct 2022 16:02:57 +0000 (+0300) Subject: Fix some pointer/reference mismatches in EventBus X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=9248910baf5bab301c7329182b143870321a95f0;p=libs%2Fgame.git Fix some pointer/reference mismatches in EventBus --- diff --git a/source/game/eventbus.h b/source/game/eventbus.h index ce9c812..e096635 100644 --- a/source/game/eventbus.h +++ b/source/game/eventbus.h @@ -57,7 +57,7 @@ private: public: template void add_observer(EventObserver &obs, std::function cb) - { get_emitter().add_observer(obs, std::move(cb)); } + { get_emitter().add_observer(&obs, std::move(cb)); } void replace_observer(EventObserver &, EventObserver &); void remove_observer(EventObserver &); @@ -94,10 +94,10 @@ inline EventDispatcher &EventBus::get_emitter() { event.dispatcher = new EventDispatcher; event.deleter = [](void *p){ delete static_cast *>(p); }; - event.remover = [](void *p, EventObserver &o){ static_cast *>(p)->remove_observer(o); }; + event.remover = [](void *p, EventObserver &o){ static_cast *>(p)->remove_observer(&o); }; } - return static_cast *>(event.dispatcher); + return *static_cast *>(event.dispatcher); } template