app_server: some missing std::nothrow and error checks.
I had app_server crash on me because of an uncaught allocation exception. I don't know if this will fix it but it's better to try to survive even if it may result in some UI glitches. Change-Id: I09dd2a7e6ff63d52f51389d7418d1a1d1810af00 Reviewed-on: https://review.haiku-os.org/c/haiku/+/1720 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
parent
fe08f0b3d0
commit
b5be469eee
@ -428,7 +428,7 @@ struct node {
|
||||
void init(const BRect& r, int32 maxPointers)
|
||||
{
|
||||
rect = r;
|
||||
pointers = new node*[maxPointers];
|
||||
pointers = new(std::nothrow) node*[maxPointers];
|
||||
in_degree = 0;
|
||||
next_pointer = 0;
|
||||
}
|
||||
@ -490,6 +490,8 @@ DrawingEngine::CopyRegion(/*const*/ BRegion* region, int32 xOffset,
|
||||
BStackOrHeapArray<node, 64> nodes(count);
|
||||
for (int32 i= 0; i < count; i++) {
|
||||
nodes[i].init(region->RectAt(i), count);
|
||||
if (nodes[i].pointers == NULL)
|
||||
return;
|
||||
}
|
||||
|
||||
for (int32 i = 0; i < count; i++) {
|
||||
@ -551,8 +553,11 @@ DrawingEngine::CopyRegion(/*const*/ BRegion* region, int32 xOffset,
|
||||
clipping_rect* sortedRectList = NULL;
|
||||
int32 nextSortedIndex = 0;
|
||||
|
||||
if (fAvailableHWAccleration & HW_ACC_COPY_REGION)
|
||||
sortedRectList = new clipping_rect[count];
|
||||
if (fAvailableHWAccleration & HW_ACC_COPY_REGION) {
|
||||
sortedRectList = new(std::nothrow) clipping_rect[count];
|
||||
if (sortedRectList == NULL)
|
||||
return;
|
||||
}
|
||||
|
||||
while (!inDegreeZeroNodes.empty()) {
|
||||
node* n = inDegreeZeroNodes.top();
|
||||
|
@ -586,8 +586,10 @@ HWInterface::_DrawCursor(IntRect area) const
|
||||
// that has the cursor blended on top of it
|
||||
|
||||
// blending buffer
|
||||
uint8* buffer = new uint8[width * height * 4];
|
||||
uint8* buffer = new(std::nothrow) uint8[width * height * 4];
|
||||
// TODO: cache this buffer
|
||||
if (buffer == NULL)
|
||||
return;
|
||||
|
||||
// offset into back buffer
|
||||
uint8* src = (uint8*)backBuffer->Bits();
|
||||
@ -1085,6 +1087,10 @@ HWInterface::_AdoptDragBitmap(const ServerBitmap* bitmap, const BPoint& offset)
|
||||
BRect cursorBounds = fCursorAndDragBitmap->Bounds();
|
||||
fCursorAreaBackup = new buffer_clip(cursorBounds.IntegerWidth() + 1,
|
||||
cursorBounds.IntegerHeight() + 1);
|
||||
if (fCursorAreaBackup->buffer == NULL) {
|
||||
delete fCursorAreaBackup;
|
||||
fCursorAreaBackup = NULL;
|
||||
}
|
||||
}
|
||||
_DrawCursor(_CursorFrame());
|
||||
}
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
#include <video_overlay.h>
|
||||
|
||||
#include <new>
|
||||
|
||||
#include "IntRect.h"
|
||||
#include "MultiLocker.h"
|
||||
#include "ServerCursor.h"
|
||||
@ -224,7 +226,7 @@ protected:
|
||||
{
|
||||
bpr = width * 4;
|
||||
if (bpr > 0 && height > 0)
|
||||
buffer = new uint8[bpr * height];
|
||||
buffer = new(std::nothrow) uint8[bpr * height];
|
||||
else
|
||||
buffer = NULL;
|
||||
left = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user