From a1e717b8f72104ba9768ba1ea6e8d1b610b7818e Mon Sep 17 00:00:00 2001 From: John Scipione Date: Fri, 20 Dec 2013 16:12:39 -0500 Subject: [PATCH] Fix crash in Message Screensaver In the Draw() method check to make sure that the view is valid, is connected to the window, that the window is locked, that the screen is valid and that the BBitmap buffer is valid. This (hopefully) fixes the last of the bugs experienced due to #4260. It is not sufficient to just check that the view is valid to prevent the crash, you must also check that it is connected to a window via Window() and that the window is locked. --- src/add-ons/screen_savers/message/Message.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/add-ons/screen_savers/message/Message.cpp b/src/add-ons/screen_savers/message/Message.cpp index 8a769851a5..9e51a717cd 100644 --- a/src/add-ons/screen_savers/message/Message.cpp +++ b/src/add-ons/screen_savers/message/Message.cpp @@ -169,9 +169,18 @@ Message::StartSaver(BView *view, bool preview) void Message::Draw(BView *view, int32 frame) { + if (view == NULL || view->Window() == NULL || !view->Window()->IsLocked()) + return; + + BScreen screen(view->Window()); + if (!screen.IsValid()) + return; + // Double-buffered drawing - BScreen screen; BBitmap buffer(view->Bounds(), screen.ColorSpace(), true); + if (buffer.InitCheck() != B_OK) + return; + BView offscreen(view->Bounds(), NULL, 0, 0); buffer.AddChild(&offscreen); buffer.Lock();