mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 20:31:56 +00:00
Initialise the application in the main thread.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@16316 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b5fa29641a
commit
888f9a3d46
2 changed files with 73 additions and 54 deletions
|
@ -1,3 +1,8 @@
|
|||
2003-04-01 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSApplication.m: ensure that application initialisation
|
||||
is performed in the main thread.
|
||||
|
||||
2003-03-31 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* Source/NSWindow.m (-becomeKeyWindow): Set initialFirstResponder.
|
||||
|
|
|
@ -559,49 +559,10 @@ static NSCell* tileCell = nil;
|
|||
* Instance methods
|
||||
*/
|
||||
|
||||
/*
|
||||
* This method initializes an NSApplication instance. It sets the
|
||||
* shared application instance to be the receiver, and then connects
|
||||
* to the window server and performs the actual gui library
|
||||
* initialization.
|
||||
*
|
||||
* If there is a already a shared application instance, calling this
|
||||
* method results in an assertion (and normally program abortion/crash).
|
||||
*
|
||||
* It is recommended that you /never/ call this method directly from
|
||||
* your code! It's called automatically (and only once) by
|
||||
* [NSApplication sharedApplication]. You might override this method
|
||||
* in subclasses (make sure to call super's :-), then your overridden
|
||||
* method will automatically be called (guaranteed once in the
|
||||
* lifetime of the application) when you call [MyApplicationClass
|
||||
* sharedApplication].
|
||||
*
|
||||
* If you call this method from your code (which we discourage you
|
||||
* from doing), it is /your/ responsibility to make sure it is called
|
||||
* only once (this is according to the openstep specification). Since
|
||||
* +sharedApplication automatically calls this method, making also
|
||||
* sure it calls it only once, you definitely want to use
|
||||
* +sharedApplication instead of calling -init directly.
|
||||
/**
|
||||
* The real gui initialisation ... called from -init
|
||||
*/
|
||||
- (id) init
|
||||
{
|
||||
/*
|
||||
* As per openstep specification, calling -init twice is a bug in
|
||||
* the program. +sharedApplication automatically makes sure it
|
||||
* never calls -init more than once, and programmers should normally
|
||||
* use +sharedApplication in programs.
|
||||
*
|
||||
* Please refrain from trying to have this method work with multiple
|
||||
* calls (such as returning NSApp instead of raising an assertion).
|
||||
* No matter what you do, you can't protect subclass -init custom
|
||||
* code from multiple executions by changing the implementation here
|
||||
* - so it's just simpler and cleaner that multiple -init executions
|
||||
* are always forbidden, and subclasses inherit exactly the same
|
||||
* kind of multiple execution protection as the superclass has, and
|
||||
* initialization code behaves always in the same way for this class
|
||||
* and for subclasses.
|
||||
*/
|
||||
NSAssert (NSApp == nil, _(@"[NSApplication -init] called more than once"));
|
||||
- (void) _init
|
||||
{
|
||||
GSDisplayServer *srv;
|
||||
/* Initialization must be enclosed in an autorelease pool. */
|
||||
|
@ -655,7 +616,60 @@ static NSCell* tileCell = nil;
|
|||
|
||||
RELEASE (_app_init_pool);
|
||||
}
|
||||
return self;
|
||||
|
||||
|
||||
/*
|
||||
* This method initializes an NSApplication instance. It sets the
|
||||
* shared application instance to be the receiver, and then connects
|
||||
* to the window server and performs the actual gui library
|
||||
* initialization.
|
||||
*
|
||||
* If there is a already a shared application instance, calling this
|
||||
* method results in an assertion (and normally program abortion/crash).
|
||||
*
|
||||
* It is recommended that you /never/ call this method directly from
|
||||
* your code! It's called automatically (and only once) by
|
||||
* [NSApplication sharedApplication]. You might override this method
|
||||
* in subclasses (make sure to call super's :-), then your overridden
|
||||
* method will automatically be called (guaranteed once in the
|
||||
* lifetime of the application) when you call [MyApplicationClass
|
||||
* sharedApplication].
|
||||
*
|
||||
* If you call this method from your code (which we discourage you
|
||||
* from doing), it is /your/ responsibility to make sure it is called
|
||||
* only once (this is according to the openstep specification). Since
|
||||
* +sharedApplication automatically calls this method, making also
|
||||
* sure it calls it only once, you definitely want to use
|
||||
* +sharedApplication instead of calling -init directly.
|
||||
*/
|
||||
- (id) init
|
||||
{
|
||||
/*
|
||||
* As per openstep specification, calling -init twice is a bug in
|
||||
* the program. +sharedApplication automatically makes sure it
|
||||
* never calls -init more than once, and programmers should normally
|
||||
* use +sharedApplication in programs.
|
||||
*
|
||||
* Please refrain from trying to have this method work with multiple
|
||||
* calls (such as returning NSApp instead of raising an assertion).
|
||||
* No matter what you do, you can't protect subclass -init custom
|
||||
* code from multiple executions by changing the implementation here
|
||||
* - so it's just simpler and cleaner that multiple -init executions
|
||||
* are always forbidden, and subclasses inherit exactly the same
|
||||
* kind of multiple execution protection as the superclass has, and
|
||||
* initialization code behaves always in the same way for this class
|
||||
* and for subclasses.
|
||||
*/
|
||||
NSAssert (NSApp == nil, _(@"[NSApplication -init] called more than once"));
|
||||
|
||||
/*
|
||||
* The appkit should run in the main thread ... so to be sure we perform
|
||||
* all the initialisation there.
|
||||
*/
|
||||
[self performSelectorOnMainThread: @selector(_init)
|
||||
withObject: self
|
||||
waitUntilDone: YES];
|
||||
return NSApp;
|
||||
}
|
||||
|
||||
- (void) finishLaunching
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue