diff --git a/src/apps/activitymonitor/ActivityView.cpp b/src/apps/activitymonitor/ActivityView.cpp index 73947ce6d1..689f79053f 100644 --- a/src/apps/activitymonitor/ActivityView.cpp +++ b/src/apps/activitymonitor/ActivityView.cpp @@ -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 diff --git a/src/apps/activitymonitor/CircularBuffer.h b/src/apps/activitymonitor/CircularBuffer.h index 5063f7d349..12ff3ada55 100644 --- a/src/apps/activitymonitor/CircularBuffer.h +++ b/src/apps/activitymonitor/CircularBuffer.h @@ -1,5 +1,5 @@ /* - * Copyright 2008, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Copyright 2008-2009, Axel Dörfler, axeld@pinc-software.de. * 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