Replaced all remaining uses of NSAutoreleasePool with @autoreleasepool blocks (bugzilla #2680.)
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
21 #include "../../SDL_internal.h"
23 #if defined(__HAIKU__)
25 /* Handle the BeApp specific portions of the application */
28 #include <storage/Path.h>
29 #include <storage/Entry.h>
32 #include "SDL_BApp.h" /* SDL_BApp class definition */
33 #include "SDL_BeApp.h"
34 #include "SDL_thread.h"
35 #include "SDL_timer.h"
36 #include "SDL_error.h"
38 #include "../../video/haiku/SDL_BWin.h"
43 /* Flag to tell whether or not the Be application is active or not */
44 int SDL_BeAppActive = 0;
45 static SDL_Thread *SDL_AppThread = NULL;
48 StartBeApp(void *unused)
52 App = new SDL_BApp("application/x-SDL-executable");
59 /* Initialize the Be Application, if it's not already started */
63 /* Create the BApplication that handles appserver interaction */
64 if (SDL_BeAppActive <= 0) {
65 SDL_AppThread = SDL_CreateThread(StartBeApp, "SDLApplication", NULL);
66 if (SDL_AppThread == NULL) {
67 return SDL_SetError("Couldn't create BApplication thread");
70 /* Change working directory to that of executable */
72 if (B_OK == be_app->GetAppInfo(&info)) {
73 entry_ref ref = info.ref;
75 if (B_OK == entry.SetTo(&ref)) {
77 if (B_OK == path.SetTo(&entry)) {
78 if (B_OK == path.GetParent(&path)) {
87 } while ((be_app == NULL) || be_app->IsLaunching());
89 /* Mark the application active */
93 /* Increment the application reference count */
96 /* The app is running, and we're ready to go */
100 /* Quit the Be Application, if there's nothing left to do */
104 /* Decrement the application reference count */
107 /* If the reference count reached zero, clean up the app */
108 if (SDL_BeAppActive == 0) {
109 if (SDL_AppThread != NULL) {
110 if (be_app != NULL) { /* Not tested */
111 be_app->PostMessage(B_QUIT_REQUESTED);
113 SDL_WaitThread(SDL_AppThread, NULL);
114 SDL_AppThread = NULL;
116 /* be_app should now be NULL since be_app has quit */
124 /* SDL_BApp functions */
125 void SDL_BApp::ClearID(SDL_BWin *bwin) {
126 _SetSDLWindow(NULL, bwin->GetID());
127 int32 i = _GetNumWindowSlots() - 1;
128 while(i >= 0 && GetSDLWindow(i) == NULL) {
134 #endif /* __HAIKU__ */
136 /* vi: set ts=4 sw=4 expandtab: */