You also need to delete cloned areas - they are areas like any other (just their

contents are shared)!
Some cleanup. BBitmap::Cleanup() doesn't ask for a reply from the server anymore
(why should it care, anyway?).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15380 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-12-06 20:12:38 +00:00
parent 7d93e66823
commit e7a77b5b71
+25 -39
View File
@@ -2254,42 +2254,36 @@ BBitmap::InitObject(BRect bounds, color_space colorSpace, uint32 flags,
// Reply Code: SERVER_FALSE
// Reply Data:
// None
int32 code = SERVER_FALSE;
error = link.FlushWithReply(code);
if (error >= B_OK) {
// *communication* with server successful
if (code == SERVER_TRUE) {
error = B_ERROR;
if (link.FlushWithReply(error) == B_OK && error == B_OK) {
// server side success
// Get token
area_id bmparea;
int32 areaoffset;
link.Read<int32>(&fServerToken);
link.Read<area_id>(&bmparea);
link.Read<int32>(&areaoffset);
area_id area;
int32 areaOffset;
link.Read<area_id>(&area);
link.Read<int32>(&areaOffset);
// Get the area in which the data resides
fArea = clone_area("shared bitmap area",
(void**)&fBasePtr,
B_ANY_ADDRESS,
B_READ_AREA | B_WRITE_AREA,
bmparea);
area);
if (fArea >= B_OK) {
// Jump to the location in the area
fBasePtr = (int8*)fBasePtr + areaoffset;
fBasePtr = (int8*)fBasePtr + areaOffset;
fSize = size;
fColorSpace = colorSpace;
fBounds = bounds;
fBytesPerRow = bytesPerRow;
fFlags = flags;
} else {
// server side error, we assume:
error = B_NO_MEMORY;
} else
error = fArea;
}
}
// NOTE: not "else" to handle B_NO_MEMORY on server side!
if (error < B_OK) {
fBasePtr = NULL;
fServerToken = -1;
@@ -2318,14 +2312,17 @@ BBitmap::InitObject(BRect bounds, color_space colorSpace, uint32 flags,
}
}
// CleanUp
/*! \brief Cleans up any memory allocated by the bitmap or
informs the server to do so.
/*!
\brief Cleans up any memory allocated by the bitmap and
informs the server to do so as well (if needed).
*/
void
BBitmap::CleanUp()
{
if (fBasePtr) {
if (fBasePtr == NULL)
return;
if (fFlags & B_BITMAP_NO_SERVER_LINK) {
free(fBasePtr);
} else {
@@ -2333,32 +2330,21 @@ BBitmap::CleanUp()
// AS_DELETE_BITMAP:
// Attached Data:
// 1) int32 server token
// Reply Code: SERVER_TRUE if successful,
// SERVER_FALSE if the buffer was already deleted
// Reply Data: none
// status_t freestat;
int32 code = SERVER_FALSE;
link.StartMessage(AS_DELETE_BITMAP);
link.Attach<int32>(fServerToken);
link.FlushWithReply(code);
if (code == SERVER_FALSE) {
// TODO: Find out if "SERVER_FALSE if the buffer
// was already deleted" is true. If not, maybe we
// need to take additional action.
}
link.Flush();
delete_area(fArea);
fArea = -1;
fServerToken = -1;
}
fBasePtr = NULL;
}
}
// AssertPtr
/*! \brief ???
*/
void
BBitmap::AssertPtr()
{
// TODO: what's this supposed to do?
}