* CircularBuffer is now save to use even if the buffer allocation failed. This
fixes bug #3985. * This happened as ViewHistory::Update() can obviously be called before the view is really layouted. Therefore it now restricts the view size to 16384. * Since the Update() happens in Draw(), it looks like this is actually a problem of our layout engine (as the size is computed via BView::Frame()). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30967 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -225,6 +225,11 @@ void
|
||||
ViewHistory::Update(DataHistory* history, int32 width, int32 resolution,
|
||||
bigtime_t toTime, bigtime_t step, bigtime_t refresh)
|
||||
{
|
||||
if (width > 16384) {
|
||||
// ignore this - it seems the view hasn't been layouted yet
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if we need to invalidate the existing values
|
||||
if ((int32)fValues.Size() != width
|
||||
|| fResolution != resolution
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008, Axel Dörfler, [email protected]. All rights reserved.
|
||||
* Copyright 2008-2009, Axel Dörfler, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef CIRCULAR_BUFFER_H
|
||||
@@ -40,7 +40,12 @@ public:
|
||||
|
||||
fSize = size;
|
||||
fBuffer = (Type*)malloc(fSize * sizeof(Type));
|
||||
return fBuffer != NULL ? B_OK : B_NO_MEMORY;
|
||||
if (fBuffer == NULL) {
|
||||
fSize = 0;
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
void MakeEmpty()
|
||||
@@ -61,7 +66,7 @@ public:
|
||||
|
||||
Type* ItemAt(int32 index) const
|
||||
{
|
||||
if (index >= (int32)fIn || index < 0)
|
||||
if (index >= (int32)fIn || index < 0 || fBuffer == NULL)
|
||||
return NULL;
|
||||
|
||||
return &fBuffer[(fFirst + index) % fSize];
|
||||
@@ -75,7 +80,8 @@ public:
|
||||
else
|
||||
index = fFirst++;
|
||||
|
||||
fBuffer[index % fSize] = item;
|
||||
if (fBuffer != NULL)
|
||||
fBuffer[index % fSize] = item;
|
||||
}
|
||||
|
||||
size_t Size() const
|
||||
|
||||
Reference in New Issue
Block a user