Message handlers are no longer cleared#589
Message handlers are no longer cleared#589alxbilger wants to merge 1 commit intosofa-framework:masterfrom
Conversation
|
You are right the presented code does not work. Because the dispatcher is a singleton of Sofa, the SofaRuntime.init() is supposed to be called before MessageHandler()... because SofaRuntime is actually the API that manipulates the singleons. To fix this I would be more in favore or designing the API so it is clear that MessageHandler is actually doing something on the "runtime" singletons. Maybe moving the MessageHandler into SofaRuntime... . |
I agree but I am in this situation because of unit testing of Python scripts. The Python script calls I am not satisfied by this PR so far. It needs more thinking. |
Currently, the following code is not working as expected:
This is because
SofaRuntime.init()removes all the messages handlers, includingmsg_handler. The consequence is that the emitted messages are not captured bymsg_handler.Instead of removing all the message handlers, I suggest to remove only
MainConsoleMessageHandler.If it's necessary to remove all the message handlers, a binding has been introduced in #588.