The app_server now cleans up better after a team crashed; not only the
application and bitmaps are removed, the team's windows are now removed as well. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13251 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -46,6 +46,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <syslog.h>
|
||||||
|
|
||||||
//#define DEBUG_SERVERAPP
|
//#define DEBUG_SERVERAPP
|
||||||
|
|
||||||
@@ -136,6 +137,48 @@ ServerApp::~ServerApp(void)
|
|||||||
if (!fQuitting)
|
if (!fQuitting)
|
||||||
CRITICAL("ServerApp: destructor called after Run()!\n");
|
CRITICAL("ServerApp: destructor called after Run()!\n");
|
||||||
|
|
||||||
|
fWindowListLock.Lock();
|
||||||
|
|
||||||
|
// quit all server windows
|
||||||
|
|
||||||
|
for (int32 i = fWindowList.CountItems(); i-- > 0;) {
|
||||||
|
ServerWindow* window = (ServerWindow*)fWindowList.ItemAt(i);
|
||||||
|
window->Quit();
|
||||||
|
}
|
||||||
|
int32 tries = fWindowList.CountItems() + 1;
|
||||||
|
|
||||||
|
fWindowListLock.Unlock();
|
||||||
|
|
||||||
|
// wait for the windows to quit
|
||||||
|
while (tries-- > 0) {
|
||||||
|
fWindowListLock.Lock();
|
||||||
|
if (fWindowList.CountItems() == 0) {
|
||||||
|
// we leave the list locked, doesn't matter anymore
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
fWindowListLock.Unlock();
|
||||||
|
snooze(10000);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tries < 0) {
|
||||||
|
// This really shouldn't happen, as it shows we're buggy
|
||||||
|
syslog(LOG_ERR, "ServerApp %s needs to kill some server windows...\n", Signature());
|
||||||
|
|
||||||
|
// there still seem to be some windows left - kill them!
|
||||||
|
fWindowListLock.Lock();
|
||||||
|
|
||||||
|
for (int32 i = 0; i < fWindowList.CountItems(); i++) {
|
||||||
|
ServerWindow* window = (ServerWindow*)fWindowList.ItemAt(i);
|
||||||
|
|
||||||
|
kill_thread(window->Thread());
|
||||||
|
window->Hide();
|
||||||
|
delete window;
|
||||||
|
}
|
||||||
|
|
||||||
|
fWindowListLock.Unlock();
|
||||||
|
}
|
||||||
|
|
||||||
// first, make sure our monitor thread doesn't
|
// first, make sure our monitor thread doesn't
|
||||||
for (int32 i = 0; i < fBitmapList.CountItems(); i++) {
|
for (int32 i = 0; i < fBitmapList.CountItems(); i++) {
|
||||||
delete static_cast<ServerBitmap *>(fBitmapList.ItemAt(i));
|
delete static_cast<ServerBitmap *>(fBitmapList.ItemAt(i));
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ ServerWindow::ServerWindow(const char *title, ServerApp *app,
|
|||||||
fMessagePort(-1),
|
fMessagePort(-1),
|
||||||
fClientReplyPort(clientPort),
|
fClientReplyPort(clientPort),
|
||||||
fClientLooperPort(looperPort),
|
fClientLooperPort(looperPort),
|
||||||
|
fQuitting(false),
|
||||||
fClientViewsWithInvalidCoords(B_VIEW_RESIZED),
|
fClientViewsWithInvalidCoords(B_VIEW_RESIZED),
|
||||||
fHandlerToken(handlerID),
|
fHandlerToken(handlerID),
|
||||||
fCurrentLayer(NULL)
|
fCurrentLayer(NULL)
|
||||||
@@ -160,6 +161,8 @@ ServerWindow::Run()
|
|||||||
void
|
void
|
||||||
ServerWindow::Quit()
|
ServerWindow::Quit()
|
||||||
{
|
{
|
||||||
|
fQuitting = true;
|
||||||
|
|
||||||
if (fThread < B_OK) {
|
if (fThread < B_OK) {
|
||||||
delete this;
|
delete this;
|
||||||
return;
|
return;
|
||||||
@@ -170,8 +173,10 @@ ServerWindow::Quit()
|
|||||||
|
|
||||||
delete this;
|
delete this;
|
||||||
exit_thread(0);
|
exit_thread(0);
|
||||||
} else
|
} else {
|
||||||
|
PostMessage(AS_HIDE_WINDOW);
|
||||||
PostMessage(kMsgWindowQuit);
|
PostMessage(kMsgWindowQuit);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -206,7 +211,7 @@ ServerWindow::Show()
|
|||||||
// NOTE: if you do something else, other than sending a port message, PLEASE lock
|
// NOTE: if you do something else, other than sending a port message, PLEASE lock
|
||||||
STRACE(("ServerWindow %s: Show\n", Title()));
|
STRACE(("ServerWindow %s: Show\n", Title()));
|
||||||
|
|
||||||
if (!fWinBorder->IsHidden())
|
if (fQuitting || !fWinBorder->IsHidden())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fWinBorder->GetRootLayer()->ShowWinBorder(fWinBorder);
|
fWinBorder->GetRootLayer()->ShowWinBorder(fWinBorder);
|
||||||
|
|||||||
@@ -141,6 +141,7 @@ private:
|
|||||||
port_id fClientLooperPort;
|
port_id fClientLooperPort;
|
||||||
|
|
||||||
BPrivate::PortLink fLink;
|
BPrivate::PortLink fLink;
|
||||||
|
bool fQuitting;
|
||||||
|
|
||||||
BMessage fClientViewsWithInvalidCoords;
|
BMessage fClientViewsWithInvalidCoords;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user