]> git.tdb.fi Git - libs/game.git/commitdiff
Fix some pointer/reference mismatches in EventBus
authorMikko Rasa <tdb@tdb.fi>
Sat, 22 Oct 2022 16:02:57 +0000 (19:02 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 22 Oct 2022 16:03:49 +0000 (19:03 +0300)
source/game/eventbus.h

index ce9c812e20b1593cbbe6489b537d4ad201f1f52f..e09663589c8c99fe02180db76b94fbe6506af54b 100644 (file)
@@ -57,7 +57,7 @@ private:
 public:
        template<typename T>
        void add_observer(EventObserver &obs, std::function<void(const T &)> cb)
-       { get_emitter<T>().add_observer(obs, std::move(cb)); }
+       { get_emitter<T>().add_observer(&obs, std::move(cb)); }
 
        void replace_observer(EventObserver &, EventObserver &);
        void remove_observer(EventObserver &);
@@ -94,10 +94,10 @@ inline EventDispatcher<T> &EventBus::get_emitter()
        {
                event.dispatcher = new EventDispatcher<T>;
                event.deleter = [](void *p){ delete static_cast<EventDispatcher<T> *>(p); };
-               event.remover = [](void *p, EventObserver &o){ static_cast<EventDispatcher<T> *>(p)->remove_observer(o); };
+               event.remover = [](void *p, EventObserver &o){ static_cast<EventDispatcher<T> *>(p)->remove_observer(&o); };
        }
 
-       return static_cast<EventDispatcher<T> *>(event.dispatcher);
+       return *static_cast<EventDispatcher<T> *>(event.dispatcher);
 }
 
 template<typename T>