* fix attaching and reading empty regions

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21909 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2007-08-12 13:07:55 +00:00
parent 5f5ba235cb
commit fddbc2311f

View File

@ -35,11 +35,15 @@ status_t
ServerLink::ReadRegion(BRegion *region)
{
fReceiver->Read(&region->fCount, sizeof(long));
fReceiver->Read(&region->fBounds, sizeof(clipping_rect));
if (!region->_SetSize(region->fCount))
return B_NO_MEMORY;
return fReceiver->Read(region->fData,
region->fCount * sizeof(clipping_rect));
if (region->fCount > 0) {
fReceiver->Read(&region->fBounds, sizeof(clipping_rect));
if (!region->_SetSize(region->fCount))
return B_NO_MEMORY;
return fReceiver->Read(region->fData,
region->fCount * sizeof(clipping_rect));
} else {
return fReceiver->Read(&region->fBounds, sizeof(clipping_rect));
}
}
@ -47,9 +51,13 @@ status_t
ServerLink::AttachRegion(const BRegion &region)
{
fSender->Attach(&region.fCount, sizeof(long));
fSender->Attach(&region.fBounds, sizeof(clipping_rect));
return fSender->Attach(region.fData,
region.fCount * sizeof(clipping_rect));
if (region.fCount > 0) {
fSender->Attach(&region.fBounds, sizeof(clipping_rect));
return fSender->Attach(region.fData,
region.fCount * sizeof(clipping_rect));
} else {
return fSender->Attach(&region.fBounds, sizeof(clipping_rect));
}
}