postEvent crashing TGB [solved] still a bug although...
by Max Kielland · in Torque Game Builder · 02/22/2013 (8:37 pm) · 2 replies
I was just going to make an event manager when I discovered that there already was one in TGB 1.7.6
I managed to create the manager, register my events, make a subscriber all without any errors, but as soon I try to post an event TGB crashes on me.
This is dumped to the console.
(null) Events
ModuleUpdate
(null) Events
ModuleUpdate Subscribers
Listener -> onModuleUpdate
As soon I execute postEvent it crashes.
I managed to create the manager, register my events, make a subscriber all without any errors, but as soon I try to post an event TGB crashes on me.
function TestClass::onModuleUpdate(%this,%data) {
echo(%this SPC %data);
}
new ScriptObject(Listener) { class = TestClass; };
new EventManager(GameEventManager);
GameEventManager.registerEvent("ModuleUpdate");
GameEventManager.subscribe(Listener,"ModuleUpdate");
GameEventManager.dumpEvents();
GameEventManager.dumpSubscribers();
GameEventManager.postEvent("ModuleUpdate","Data");This is dumped to the console.
(null) Events
ModuleUpdate
(null) Events
ModuleUpdate Subscribers
Listener -> onModuleUpdate
As soon I execute postEvent it crashes.
About the author
Owner of MK Development www.mkdevelopment.se
#2
02/24/2013 (10:51 am)
<shrug> More of a lack of documentation, though I agree it shouldn't crash. Every event manager object I've ever seen sets this field, so I never tried to create one without it and didn't know this caused a crash.
Torque Owner Max Kielland
MK Development
It turned out that there is an undocumented field (Queue) that has to be set, otherwise it will crash the whole TGB (...and you think this would have been caught in QA tests).
Here is the working code:
new ScriptObject(Listener) { class = TestClass; }; new EventManager(GameEventManager) { queue = "EventQueue";} ; GameEventManager.registerEvent("ModuleUpdate"); GameEventManager.subscribe(Listener,"ModuleUpdate"); GameEventManager.dumpEvents(); GameEventManager.dumpSubscribers(); GameEventManager.postEvent("ModuleUpdate","Data"); function TestClass::onModuleUpdate(%this,%data) { echo(%this SPC %data); }