While working on my uni project, I found a small bug in the engine
plugin, that was introduced with the new event system.
csEngine::Initialize() will segfault on line 815 of
plugins/engine/3d/engine.cpp by referencing a null pointer, if either of
the iGraphics2D or 3D plugins is not available. The engine is still
supposed to be able to function without those plugins.
The fix is quite trivial. Attached is a patch, as I lost my CVS write
access during the spring clean. You might want to apply the patch or you
might want to just do it yourself if you want to fix it in a different way.
diff -c -3 -r1.106 engine.cpp
*** plugins/engine/3d/engine.cpp 8 Dec 2005 07:30:47 -0000 1.106
--- plugins/engine/3d/engine.cpp 15 Dec 2005 17:22:54 -0000
***************
*** 812,819 ****
// Tell event queue that we want to handle broadcast events
CS_INITIALIZE_SYSTEM_EVENT_SHORTCUTS(objectRegistry);
! CanvasResize = csevCanvasResize (objectRegistry, G2D);
! CanvasClose = csevCanvasClose (objectRegistry, G2D);
csRef<iEventQueue> q = CS_QUERY_REGISTRY (objectRegistry, iEventQueue);
if (q)
--- 812,822 ----
// Tell event queue that we want to handle broadcast events
CS_INITIALIZE_SYSTEM_EVENT_SHORTCUTS(objectRegistry);
! if (G2D)
! {
! CanvasResize = csevCanvasResize (objectRegistry, G2D);
! CanvasClose = csevCanvasClose (objectRegistry, G2D);
! }
csRef<iEventQueue> q = CS_QUERY_REGISTRY (objectRegistry, iEventQueue);
if (q)
***************
*** 821,826 ****
--- 824,833 ----
csEventID events[5] = { SystemOpen, SystemClose,
CanvasResize, CanvasClose,
CS_EVENTLIST_END };
+
+ // discard canvas events if there is no canvas, by truncating the array
+ if (!G2D) events[2] = CS_EVENTLIST_END;
+
q->RegisterListener (scfiEventHandler, events);
}