I wrote two custom components, one is a node component and another is the scene component. Let’s name them myBody and myWorld, kinda like PhysicsWorld that takes care of all collision shapes and rigid bodies, myWorld takes care of all myBodies. And just like in RigidBody.cpp, myBody uses GetOrCreateComponent to register into myWorld.
Problem is, I sometimes getting multiple instances of myWorld and it breaks everything. Did I missed something in registration process? Can anyone hint me on how Urho does this check for its native subsystems?
I wonder why you try to create multiple instances of component which should not be there…
But in case you want to debug this, you can create static class member counter and increment it in constructor.
And check thatthe resulting value is not > 1 (you also need to disable copy-constructor). In that case you can assert exit your app like abort() and get backtrace of the result.
Urho actually does not have checks for protecting against multiple subsystems. From what I remember, if you were to do it at the Context-level, the old subsystem would just be thrown out. For the scene subsystem components, there likewise is no checks (as recovery options are not obvious, should it delete the old one, crash, complain, or what?) so it’s just a programmer error you should avoid.