Fixed number 1 (or the only one? ;-)) crashing bug #306 in the app_server:
Since ServerWindow removed itself from its ServerApp in _PrepareQuit(), it could happen quite easily that the ServerApp was deleted before the ServerWindow - and since deleting WindowLayer as part of that referenced the ServerApp, it crashed. Now, adding/removing is both done by the ServerWindow in Init() respectively the destructor. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17198 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -2468,27 +2468,27 @@ ServerApp::_CreateWindow(int32 code, BPrivate::LinkReceiver& link,
|
|||||||
status = window->Init(frame, (window_look)look, (window_feel)feel,
|
status = window->Init(frame, (window_look)look, (window_feel)feel,
|
||||||
flags, workspaces);
|
flags, workspaces);
|
||||||
if (status == B_OK && !window->Run()) {
|
if (status == B_OK && !window->Run()) {
|
||||||
fprintf(stderr, "ServerApp::_CreateWindow() - failed to run the window thread\n");
|
fprintf(stderr, "ServerApp::_CreateWindow() - failed to run the window thread\n");
|
||||||
status = B_ERROR;
|
status = B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the window to the list
|
if (status < B_OK)
|
||||||
if (status == B_OK && fWindowListLock.Lock()) {
|
|
||||||
status = fWindowList.AddItem(window) ? B_OK : B_NO_MEMORY;
|
|
||||||
if (status < B_OK)
|
|
||||||
fprintf(stderr, "ServerApp::_CreateWindow() - no memory to add window to list\n");
|
|
||||||
fWindowListLock.Unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status < B_OK) {
|
|
||||||
delete window;
|
delete window;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
ServerApp::AddWindow(ServerWindow* window)
|
||||||
|
{
|
||||||
|
BAutolock locker(fWindowListLock);
|
||||||
|
|
||||||
|
return fWindowList.AddItem(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ServerApp::RemoveWindow(ServerWindow* window)
|
ServerApp::RemoveWindow(ServerWindow* window)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ class ServerApp : public MessageLooper {
|
|||||||
const char* Signature() const { return fSignature.String(); }
|
const char* Signature() const { return fSignature.String(); }
|
||||||
const char* SignatureLeaf() const { return fSignature.String() + 12; }
|
const char* SignatureLeaf() const { return fSignature.String() + 12; }
|
||||||
|
|
||||||
|
bool AddWindow(ServerWindow* window);
|
||||||
void RemoveWindow(ServerWindow* window);
|
void RemoveWindow(ServerWindow* window);
|
||||||
bool InWorkspace(int32 index) const;
|
bool InWorkspace(int32 index) const;
|
||||||
uint32 Workspaces() const;
|
uint32 Workspaces() const;
|
||||||
|
|||||||
@@ -194,6 +194,9 @@ ServerWindow::~ServerWindow()
|
|||||||
|
|
||||||
delete fWindowLayer;
|
delete fWindowLayer;
|
||||||
|
|
||||||
|
if (App() != NULL)
|
||||||
|
App()->RemoveWindow(this);
|
||||||
|
|
||||||
free(fTitle);
|
free(fTitle);
|
||||||
delete_port(fMessagePort);
|
delete_port(fMessagePort);
|
||||||
|
|
||||||
@@ -220,6 +223,11 @@ status_t
|
|||||||
ServerWindow::Init(BRect frame, window_look look, window_feel feel,
|
ServerWindow::Init(BRect frame, window_look look, window_feel feel,
|
||||||
uint32 flags, uint32 workspace)
|
uint32 flags, uint32 workspace)
|
||||||
{
|
{
|
||||||
|
if (!App()->AddWindow(this)) {
|
||||||
|
fServerApp = NULL;
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
if (fTitle == NULL)
|
if (fTitle == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
@@ -278,8 +286,6 @@ ServerWindow::_PrepareQuit()
|
|||||||
fDesktop->LockSingleWindow();
|
fDesktop->LockSingleWindow();
|
||||||
_Hide();
|
_Hide();
|
||||||
fDesktop->UnlockSingleWindow();
|
fDesktop->UnlockSingleWindow();
|
||||||
|
|
||||||
App()->RemoveWindow(this);
|
|
||||||
} else if (fThread >= B_OK)
|
} else if (fThread >= B_OK)
|
||||||
PostMessage(AS_HIDE_WINDOW);
|
PostMessage(AS_HIDE_WINDOW);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user