[Haiku-commits] r30967 - haiku/trunk/src/apps/activitymonitor
axeld at mail.berlios.de
axeld at mail.berlios.de
Fri Jun 5 10:20:49 CEST 2009
Author: axeld
Date: 2009-06-05 10:20:43 +0200 (Fri, 05 Jun 2009)
New Revision: 30967
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30967&view=rev
Modified:
haiku/trunk/src/apps/activitymonitor/ActivityView.cpp
haiku/trunk/src/apps/activitymonitor/CircularBuffer.h
Log:
* 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()).
Modified: haiku/trunk/src/apps/activitymonitor/ActivityView.cpp
===================================================================
--- haiku/trunk/src/apps/activitymonitor/ActivityView.cpp 2009-06-05 08:14:31 UTC (rev 30966)
+++ haiku/trunk/src/apps/activitymonitor/ActivityView.cpp 2009-06-05 08:20:43 UTC (rev 30967)
@@ -225,6 +225,11 @@
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
Modified: haiku/trunk/src/apps/activitymonitor/CircularBuffer.h
===================================================================
--- haiku/trunk/src/apps/activitymonitor/CircularBuffer.h 2009-06-05 08:14:31 UTC (rev 30966)
+++ haiku/trunk/src/apps/activitymonitor/CircularBuffer.h 2009-06-05 08:20:43 UTC (rev 30967)
@@ -1,5 +1,5 @@
/*
- * Copyright 2008, Axel Dörfler, axeld at pinc-software.de. All rights reserved.
+ * Copyright 2008-2009, Axel Dörfler, axeld at pinc-software.de.
* Distributed under the terms of the MIT License.
*/
#ifndef CIRCULAR_BUFFER_H
@@ -40,7 +40,12 @@
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 @@
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 @@
else
index = fFirst++;
- fBuffer[index % fSize] = item;
+ if (fBuffer != NULL)
+ fBuffer[index % fSize] = item;
}
size_t Size() const
More information about the Haiku-commits
mailing list