From 0aa69a9cd4f37a6f343d6d7dfc74aded88c25916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 8 Jun 2005 01:40:22 +0000 Subject: [PATCH] Fixed the crashing bug when quitting the app_server. The display driver is now owned by the Screen object. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13002 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/AppServer.cpp | 35 +++++++++++++------------------- src/servers/app/Desktop.cpp | 4 +++- src/servers/app/ServerScreen.cpp | 4 +--- 3 files changed, 18 insertions(+), 25 deletions(-) diff --git a/src/servers/app/AppServer.cpp b/src/servers/app/AppServer.cpp index 027c8b6108..9a7cb6f7bc 100644 --- a/src/servers/app/AppServer.cpp +++ b/src/servers/app/AppServer.cpp @@ -761,35 +761,30 @@ AppServer::DispatchMessage(int32 code, BPortLink &msg) Broadcast(AS_QUIT_APP); // we have to wait until *all* threads have finished! - ServerApp *app= NULL; + ServerApp *app; acquire_sem(fAppListLock); thread_info tinfo; - for(int32 i= 0; i < fAppList->CountItems(); i++) - { - app=(ServerApp*)fAppList->ItemAt(i); - if(!app) + for (int32 i = 0; i < fAppList->CountItems(); i++) { + app = (ServerApp*)fAppList->ItemAt(i); + if (!app) continue; - + // Instead of calling wait_for_thread, we will wait a bit, check for the // thread_id. We will only wait so long, because then the app is probably crashed // or hung. Seeing that being the case, we'll kill its BApp team and fake the // quit message - if(get_thread_info(app->MonitorThreadID(), &tinfo)==B_OK) - { - bool killteam=true; - - for(int32 j=0; j<5; j++) - { + if (get_thread_info(app->MonitorThreadID(), &tinfo)==B_OK) { + bool killteam = true; + + for (int32 j = 0; j < 5; j++) { snooze(500000); // wait half a second for it to quit - if(get_thread_info(app->MonitorThreadID(), &tinfo)!=B_OK) - { - killteam=false; + if (get_thread_info(app->MonitorThreadID(), &tinfo) != B_OK) { + killteam = false; break; } } - - if(killteam) - { + + if (killteam) { kill_team(app->ClientTeamID()); app->PostMessage(B_QUIT_REQUESTED); } @@ -804,11 +799,9 @@ AppServer::DispatchMessage(int32 code, BPortLink &msg) delete fAppList; delete bitmapmanager; delete fontserver; - make_decorator=NULL; - - exit_thread(0); // we are now clear to exit + exit_thread(0); #endif break; } diff --git a/src/servers/app/Desktop.cpp b/src/servers/app/Desktop.cpp index 59da593de0..de8c5e735a 100644 --- a/src/servers/app/Desktop.cpp +++ b/src/servers/app/Desktop.cpp @@ -102,8 +102,10 @@ void Desktop::AddDriver(DisplayDriver *driver) { if (driver->Initialize()) { - // TODO: be careful of screen initialization - monitor may not support 640x480 Screen *screen = new Screen(driver, fScreenList.CountItems() + 1); + // The driver is now owned by the screen + + // TODO: be careful of screen initialization - monitor may not support 640x480 screen->SetMode(640, 480, B_RGB32, 60.f); fScreenList.AddItem(screen); diff --git a/src/servers/app/ServerScreen.cpp b/src/servers/app/ServerScreen.cpp index 1ae97de4bc..032eb0877a 100644 --- a/src/servers/app/ServerScreen.cpp +++ b/src/servers/app/ServerScreen.cpp @@ -48,9 +48,7 @@ Screen::Screen(DisplayDriver *driver, int32 id) Screen::~Screen(void) { -//printf("~Screen( %ld )\n", fID); - // TODO: Who is supposed to delete the display driver? It's ours, no? -// delete fDDriver; + delete fDriver; }