From: <gr...@gm...> - 2003-01-18 17:21:05
|
Hello, in the thing plugin i found a little bug. To reproduce the error you can try to run "awstest", and see if you get an NULL pointer exception. If I load the engine using: engine = CS_LOAD_PLUGIN(plugin_mgr, "crystalspace.engine.3d", iEngine); and then register it in the object registry afterwards with: object_reg->Register (engine, "iEngine"); I will surely get what I do not want, because when I load the engine plugin (in the above LOAD_PLUGIN(...)), the C++ code of the "thing" plugin mesh assumes that the engine was already registered inside the object registry: in fact in the initialization of the "engine" plugin: bool csEngine::Initialize (iObjectRegistry *object_reg) { ..... if (!thing_type) { thing_type = CS_LOAD_PLUGIN (plugin_mgr,"crystalspace.mesh.object.thing", iMeshObjectType); .... as usually, CS_LOAD_PLUGIN will then call: bool csThingObjectType::Initialize (iObjectRegistry *object_reg) { csThingObjectType::object_reg = object_reg; csRef<iEngine> e = CS_QUERY_REGISTRY (object_reg, iEngine);<<<<<<<<<<<<<<<<<!!!!!!!!! engine = e; // We don't want a real ref here to avoid circular refs. which will set the "engine" member variable of the class csThingObjectType to NULL, if the engine plugin was not already registered. A simple patch could be that the engine register itself into the register, such as: bool csEngine::Initialize (iObjectRegistry *object_reg) { csEngine::object_reg = object_reg; object_reg->Register (this,"iEngine");//ADD THIS LINE!!!!! virtual_clock = CS_QUERY_REGISTRY (object_reg, iVirtualClock); if (!virtual_clock) return false; ........... Greetings! p.s. I noticed that the method "bool csObjectRegistry::Register (iBase*, char const* tag) ;" returns "false" if "tag" was already used. So for example if i register the same csEngine object 2 time i.e.: objReg->Register(engine,"iEngine");//this will returns true objReg->Register(engine,"iEngine");//this will returns false and the second call will return "false", but it should return "true" IMO, that is: bool csObjectRegistry::Register (iBase* obj, char const* tag) { ........... if (o) { // DecRef() o because Get() already increffed it. if(o == obj)//LINE ADDED {//LINE ADDED o->DecRef (); return true; //LINE ADDED }//LINE ADDED o->DecRef (); return false; } |