From f277acc9cd89243e00e3c63578abcb2be670040c Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Sat, 22 Aug 2009 14:14:17 +0000 Subject: [PATCH] Don't crash the app server if the user calls BScreen(BWindow *) supplying an offscreen window (Magnify does that, and that's the cause of ticket #4304). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32611 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/ServerApp.cpp | 4 +++- src/servers/app/ServerWindow.cpp | 10 ++++++++++ src/servers/app/ServerWindow.h | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/servers/app/ServerApp.cpp b/src/servers/app/ServerApp.cpp index c9efd15de7..ed589b1764 100644 --- a/src/servers/app/ServerApp.cpp +++ b/src/servers/app/ServerApp.cpp @@ -2264,9 +2264,11 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link) for (int32 i = fWindowList.CountItems(); i-- > 0;) { ServerWindow* window = fWindowList.ItemAt(i); - + if (window->ClientToken() == clientToken) { // found it! + if (window->IsOffscreen()) + break; fLink.StartMessage(B_OK); fLink.Attach(window->Window()->Screen()->ID()); status = B_OK; diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp index ec7141f976..daff8c6693 100644 --- a/src/servers/app/ServerWindow.cpp +++ b/src/servers/app/ServerWindow.cpp @@ -671,6 +671,16 @@ ServerWindow::Window() const } +bool +ServerWindow::IsOffscreen() const +{ + // TODO: ensure desktop is locked! + // TODO: ensure the Window has been created! + + return fWindow->IsOffscreenWindow(); +} + + View* ServerWindow::_CreateView(BPrivate::LinkReceiver& link, View** _parent) { diff --git a/src/servers/app/ServerWindow.h b/src/servers/app/ServerWindow.h index db16a0b368..527f3a9871 100644 --- a/src/servers/app/ServerWindow.h +++ b/src/servers/app/ServerWindow.h @@ -84,6 +84,7 @@ public: inline ServerApp* App() const { return fServerApp; } ::Desktop* Desktop() const { return fDesktop; } ::Window* Window() const; + bool IsOffscreen() const; void SetTitle(const char* newTitle); inline const char* Title() const { return fTitle; }