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.
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user