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 Code: SERVER_FALSE
// Reply Data: // Reply Data:
// None // None
int32 code = SERVER_FALSE; error = B_ERROR;
error = link.FlushWithReply(code); if (link.FlushWithReply(error) == B_OK && error == B_OK) {
if (error >= B_OK) {
// *communication* with server successful
if (code == SERVER_TRUE) {
// server side success // server side success
// Get token // Get token
area_id bmparea;
int32 areaoffset;
link.Read<int32>(&fServerToken); 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 // Get the area in which the data resides
fArea = clone_area("shared bitmap area", fArea = clone_area("shared bitmap area",
(void**)&fBasePtr, (void**)&fBasePtr,
B_ANY_ADDRESS, B_ANY_ADDRESS,
B_READ_AREA | B_WRITE_AREA, B_READ_AREA | B_WRITE_AREA,
bmparea); area);
if (fArea >= B_OK) {
// Jump to the location in the area // Jump to the location in the area
fBasePtr = (int8*)fBasePtr + areaoffset; fBasePtr = (int8*)fBasePtr + areaOffset;
fSize = size; fSize = size;
fColorSpace = colorSpace; fColorSpace = colorSpace;
fBounds = bounds; fBounds = bounds;
fBytesPerRow = bytesPerRow; fBytesPerRow = bytesPerRow;
fFlags = flags; fFlags = flags;
} else { } else
// server side error, we assume: error = fArea;
error = B_NO_MEMORY;
} }
}
// NOTE: not "else" to handle B_NO_MEMORY on server side!
if (error < B_OK) { if (error < B_OK) {
fBasePtr = NULL; fBasePtr = NULL;
fServerToken = -1; 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 void
BBitmap::CleanUp() BBitmap::CleanUp()
{ {
if (fBasePtr) { if (fBasePtr == NULL)
return;
if (fFlags & B_BITMAP_NO_SERVER_LINK) { if (fFlags & B_BITMAP_NO_SERVER_LINK) {
free(fBasePtr); free(fBasePtr);
} else { } else {
@@ -2333,32 +2330,21 @@ BBitmap::CleanUp()
// AS_DELETE_BITMAP: // AS_DELETE_BITMAP:
// Attached Data: // Attached Data:
// 1) int32 server token // 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.StartMessage(AS_DELETE_BITMAP);
link.Attach<int32>(fServerToken); link.Attach<int32>(fServerToken);
link.FlushWithReply(code); link.Flush();
if (code == SERVER_FALSE) {
// TODO: Find out if "SERVER_FALSE if the buffer delete_area(fArea);
// was already deleted" is true. If not, maybe we
// need to take additional action.
}
fArea = -1; fArea = -1;
fServerToken = -1; fServerToken = -1;
} }
fBasePtr = NULL; fBasePtr = NULL;
} }
}
// AssertPtr
/*! \brief ???
*/
void void
BBitmap::AssertPtr() BBitmap::AssertPtr()
{ {
// TODO: what's this supposed to do?
} }