Merge lp:~alan-griffiths/compiz-core/init-sequence-fix into lp:compiz-core/0.9.5
Proposed by
Alan Griffiths
Status: | Merged |
---|---|
Approved by: | Sam Spilsbury |
Approved revision: | 2976 |
Merged at revision: | 2978 |
Proposed branch: | lp:~alan-griffiths/compiz-core/init-sequence-fix |
Merge into: | lp:compiz-core/0.9.5 |
Diff against target: |
60 lines (+5/-6) 2 files modified
src/screen.cpp (+1/-2) xslt/bcop.xslt (+4/-4) |
To merge this branch: | bzr merge lp:~alan-griffiths/compiz-core/init-sequence-fix |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Compiz Maintainers | Pending | ||
Review via email: mp+91039@code.launchpad.net |
Description of the change
CompManager::init() creates a CompScreen object (and will, after construction, store it's address in ::screen).
In the constructor of CompScreen a PrivateScreen object is constructed. This has a base subobject of type CoreOptions.
The constructor of CoreOptions NO LONGER dereferences the ::screen variable (to call CompScreen:
Calling a member function via an invalid (0 in this case) pointer was "undefined behaviour".
To post a comment you must log in.
29 - <xsl:text> screen->addAction (&</xsl:text> mOptions[ </xsl:text>
30 + <xsl:text> if (screen) screen->addAction (&</xsl:text>
31 <xsl:text>
Hrmm. Not sure if I like the idea of doing nul checks just to handle the startup case in CoreOptions.
To be honest, the option code shouldn't really be initialized until a plugin which is in charge of doing all the settings is loaded (eg, ccp). I would say it might be more appropriate here to allow *Options classes to have a default parameter in their constructor which indicates that they would rather have the options code initialized lazily, eg, in the bcop generated files, have a static bool initialized = false; variable and then atomically initialize the options whenever they are first written to, accessed or an action is bound.
That gains us a bit of startup time too, if we do it like that. Not really sure what the cost of having a once-only section optionGet* is, though I'm pretty sure there are compiler hints to deal with that no ?