[haiku-commits] haiku: hrev46570 - src/add-ons/screen_savers/message

  • From: jscipione@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 20 Dec 2013 22:13:51 +0100 (CET)

hrev46570 adds 1 changeset to branch 'master'
old head: 5d7f782d4e505cb5788cdfb2abf7bdd174af084e
new head: a1e717b8f72104ba9768ba1ea6e8d1b610b7818e
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=a1e717b+%5E5d7f782

----------------------------------------------------------------------------

a1e717b: 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.

                                     [ John Scipione <jscipione@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev46570
Commit:      a1e717b8f72104ba9768ba1ea6e8d1b610b7818e
URL:         http://cgit.haiku-os.org/haiku/commit/?id=a1e717b
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Fri Dec 20 21:12:39 2013 UTC

Ticket:      https://dev.haiku-os.org/ticket/4260

----------------------------------------------------------------------------

1 file changed, 10 insertions(+), 1 deletion(-)
src/add-ons/screen_savers/message/Message.cpp | 11 ++++++++++-

----------------------------------------------------------------------------

diff --git a/src/add-ons/screen_savers/message/Message.cpp 
b/src/add-ons/screen_savers/message/Message.cpp
index 8a76985..9e51a71 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();


Other related posts:

  • » [haiku-commits] haiku: hrev46570 - src/add-ons/screen_savers/message - jscipione