Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global console variables are being defined more than once #178

Open
lukaspj opened this issue May 30, 2020 · 0 comments
Open

Global console variables are being defined more than once #178

lukaspj opened this issue May 30, 2020 · 0 comments

Comments

@lukaspj
Copy link
Contributor

lukaspj commented May 30, 2020

This issue was created in the GarageGames Repository (Link to original issue).
The issue was originally created by @jamesu and had a total of 2 comments that may contain additional information. The original issue description is pasted below:

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:

  1. Create an empty consoleInit function in the next derived class.

  2. Use a more flat class hierarchy.

  3. Expose consoleInit in some other way which prevents this duplication.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant