Could Someone Please explain the function Object:OnEvent?

// Make a copy of the context pointer in case the object is destroyed during event handler invocation
    Context* context = context_;
    EventHandler* specific = nullptr;
    EventHandler* nonSpecific = nullptr;

The comment “Make a copy …” really confuse me, the code Context* context = context_ really is a pointer assignment,
the content of context_ is not copied to context , so if context_ is destroyed , say context_ = nullptr, so context is also
be invalid to use, because they are point to the same address.

It will be appreciate if someone explain the code a bit more.
I recently wanted to learn an open source game engine, so I try to read the source and fing out what it was doing.

Context is considered as immortal object among any other Objects, so it’s never destructed in any function.
However, event processing could destroy the object, so context_ become invalid.

If you have small quetions like this, it’s probably makes sence to ask them here

Eugene , thanks for you reply.
You mean the event receiver itself may be destroyed during event processing?
Is there Only one Context object living in the whole lifetime of the engine run time ?

Gitter is a good place, I will post my left small question there to see if it would be overwhelmed by others discussions

Exactly.

In most cases you don’t need more that one context.
There is nothing wrong in creating and using multiple ones tho.

However, I don’t recommend to run multiple instances of the engine in separate contextes, because it’s only theoretically working and almost untested.

In summary, you could use as much contextes as you need, but don’t create more than one Engine.