You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After modifying the console variable system I noticed that console variables were being added more than once in Con::init. If for example you put a breakpoint in "EditTSCtrl::consoleInit()", you'll notice its called at least 12 times. For "ShapeBase::consoleInit()", 8 times.
The issue seems to be when you don't override consoleInit in a derived class the ConcreteClassRep helper ends up calling the nearest implementation in a base class. Since ::consoleInit() is only usually used to define global variables, the extra calls are essentially redundant.
e.g.
// Calls MyConsoleObject::consoleInit during console init, great!
class MyConsoleObject : SimObject {
static void consoleInit();
};
// Calls MyConsoleObject::consoleInit() during console init, ...
class MyDerivedConsoleObject : MyConsoleObject {
};
// Still calls MyConsoleObject::consoleInit() during console init, ...
class MyOtherConsoleObject : MyDerivedConsoleObject {
};
Possible solutions:
Create an empty consoleInit function in the next derived class.
Use a more flat class hierarchy.
Expose consoleInit in some other way which prevents this duplication.
The text was updated successfully, but these errors were encountered:
Does this also mean that some calls to the parent consoleInit are also redundant? I've got a bit of code together to add missing consoleInit static methods to the relevant child classes, but I wasn't sure if this also should be cleaned up.
Thanks for the catch. I think the simplest solution for now is to create stubs in derived classes and update the documentation in ConsoleObject to make this clear (IIRC, that class has documentation about deriving new subclasses).
After modifying the console variable system I noticed that console variables were being added more than once in Con::init. If for example you put a breakpoint in "EditTSCtrl::consoleInit()", you'll notice its called at least 12 times. For "ShapeBase::consoleInit()", 8 times.
The issue seems to be when you don't override consoleInit in a derived class the ConcreteClassRep helper ends up calling the nearest implementation in a base class. Since ::consoleInit() is only usually used to define global variables, the extra calls are essentially redundant.
e.g.
Possible solutions:
Create an empty consoleInit function in the next derived class.
Use a more flat class hierarchy.
Expose consoleInit in some other way which prevents this duplication.
The text was updated successfully, but these errors were encountered: