diff --git a/src/add-ons/screen_savers/spider/SpiderSaver.cpp b/src/add-ons/screen_savers/spider/SpiderSaver.cpp index 7a78faf7da..eddc571ad5 100644 --- a/src/add-ons/screen_savers/spider/SpiderSaver.cpp +++ b/src/add-ons/screen_savers/spider/SpiderSaver.cpp @@ -213,14 +213,12 @@ SpiderSaver::_Init(BRect bounds) maxQueueDepth /= 4; } for (uint32 i = 0; i < fQueueNumber; i++) - fQueues[i] = new PolygonQueue(new Polygon(bounds, minPoints - + lrand48() - % (maxPoints - - minPoints)), - minQueueDepth + lrand48() % (maxQueueDepth - - minQueueDepth)); + fQueues[i] = new PolygonQueue(new Polygon(bounds, + minPoints + lrand48() % (maxPoints - minPoints)), + minQueueDepth + lrand48() % (maxQueueDepth - minQueueDepth)); } + // _Cleanup void SpiderSaver::_Cleanup() @@ -232,6 +230,7 @@ SpiderSaver::_Cleanup() } } + // _AllocBackBitmap void SpiderSaver::_AllocBackBitmap(float width, float height) @@ -241,11 +240,18 @@ SpiderSaver::_AllocBackBitmap(float width, float height) return; BRect b(0.0, 0.0, width, height); - fBackBitmap = new BBitmap(b, B_RGB32, true); + fBackBitmap = new(std::nothrow) BBitmap(b, B_RGB32, true); if (!fBackBitmap) return; + if (fBackBitmap->IsValid()) { - fBackView = new BView(b, 0, B_FOLLOW_NONE, B_WILL_DRAW); + fBackView = new(std::nothrow) BView(b, 0, B_FOLLOW_NONE, B_WILL_DRAW); + if (fBackView == NULL) { + _FreeBackBitmap(); + fprintf(stderr, + "SpiderSaver::_AllocBackBitmap(): view allocation failed\n"); + return; + } fBackBitmap->AddChild(fBackView); memset(fBackBitmap->Bits(), 0, fBackBitmap->BitsLength()); } else { @@ -254,6 +260,7 @@ SpiderSaver::_AllocBackBitmap(float width, float height) } } + // _FreeBackBitmap void SpiderSaver::_FreeBackBitmap() @@ -265,6 +272,7 @@ SpiderSaver::_FreeBackBitmap() } } + // _DrawInto void SpiderSaver::_DrawInto(BView *view)