|
From: | Richard Frith-Macdonald |
Subject: | Re: has my bug report & fix been submitted (in NSProcessInfo.m)? |
Date: | Wed, 20 Jul 2005 05:58:03 +0100 |
On 2005-07-19 15:18:19 +0100 Andrew Ruder <aeruder@ksu.edu> wrote:
Lloyd Dupont wrote:here was the fix: NSProcessInfo.m: 669 + (void) initialize { if (self == [NSProcessInfo class] && !_gnu_environment) _gnu_process_args(__argc, __argv, _environ); } I add the "&& !_gnu_environment" testI don't think this could possibly be the correct fix. This is just duct-taping a fix over something else which is obviously broken... Aren't + initialize methods only supposed to be called once?
The 'self == [NSProcessInfo class]' clause is a standard/common thing ... to protect against the case where a subclass calls +initialize (yes, it can get called more than once ... it's just that the runtime guaranteese to call it once before calling other methods of the class).
The !_gnu_environment is the important bit ... to prevent _gnu_process_args(__argc, __argv, _environ) being called by +initialize if it has already been called. On windows, I think it is normally called in the fake main process, before +initialize is called.
I believe Lloyd needed to do this because he had initialised NSProcessInfo values with a custom version of the environment, and didn't want a later call to +initialize to overwrite stuff with environment information from the _environ global variable.
Basically, _gnu_process_args() can be called before +initialize, so it's good for +initialise to not call it again under those circumstances.
[Prev in Thread] | Current Thread | [Next in Thread] |