* Bitmaps and pictures now maintain their client reference independently;
clients can no longer release more references than they own. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34130 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -784,7 +784,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
||||
STRACE(("ServerApp %s: Deleting Bitmap %ld\n", Signature(),
|
||||
token));
|
||||
|
||||
bitmap->ReleaseReference();
|
||||
bitmap->ReleaseClientReference();
|
||||
}
|
||||
|
||||
fMapLocker.Unlock();
|
||||
@@ -872,7 +872,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
||||
|
||||
ServerPicture* picture = _FindPicture(token);
|
||||
if (picture != NULL)
|
||||
picture->ReleaseReference();
|
||||
picture->ReleaseClientReference();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,8 @@ ServerBitmap::ServerBitmap(BRect rect, color_space space, uint32 flags,
|
||||
fBytesPerRow(0),
|
||||
fSpace(space),
|
||||
fFlags(flags),
|
||||
fOwner(NULL)
|
||||
fOwner(NULL),
|
||||
fHasClientReference(true)
|
||||
// fToken is initialized (if used) by the BitmapManager
|
||||
{
|
||||
int32 minBytesPerRow = get_bytes_per_row(space, fWidth);
|
||||
@@ -91,7 +92,8 @@ ServerBitmap::ServerBitmap(const ServerBitmap* bitmap)
|
||||
fAllocationCookie(NULL),
|
||||
fOverlay(NULL),
|
||||
fBuffer(NULL),
|
||||
fReferenceCount(1)
|
||||
fReferenceCount(1),
|
||||
fHasClientReference(false)
|
||||
{
|
||||
if (bitmap) {
|
||||
fWidth = bitmap->fWidth;
|
||||
@@ -220,6 +222,18 @@ ServerBitmap::Owner() const
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
ServerBitmap::ReleaseClientReference()
|
||||
{
|
||||
if (!fHasClientReference)
|
||||
return false;
|
||||
|
||||
fHasClientReference = false;
|
||||
ReleaseReference();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ServerBitmap::PrintToStream()
|
||||
{
|
||||
|
||||
@@ -72,6 +72,8 @@ public:
|
||||
bool SetOwner(ServerApp* owner);
|
||||
ServerApp* Owner() const;
|
||||
|
||||
bool ReleaseClientReference();
|
||||
|
||||
//! Does a shallow copy of the bitmap passed to it
|
||||
inline void ShallowCopy(const ServerBitmap *from);
|
||||
|
||||
@@ -112,6 +114,7 @@ protected:
|
||||
|
||||
ServerApp* fOwner;
|
||||
int32 fToken;
|
||||
bool fHasClientReference;
|
||||
};
|
||||
|
||||
class UtilityBitmap : public ServerBitmap {
|
||||
|
||||
@@ -784,7 +784,8 @@ ServerPicture::ServerPicture()
|
||||
fFile(NULL),
|
||||
fPictures(NULL),
|
||||
fUsurped(NULL),
|
||||
fOwner(NULL)
|
||||
fOwner(NULL),
|
||||
fHasClientReference(true)
|
||||
{
|
||||
fToken = gTokenSpace.NewToken(kPictureToken, this);
|
||||
fData = new(std::nothrow) BMallocIO();
|
||||
@@ -799,7 +800,8 @@ ServerPicture::ServerPicture(const ServerPicture& picture)
|
||||
fData(NULL),
|
||||
fPictures(NULL),
|
||||
fUsurped(NULL),
|
||||
fOwner(NULL)
|
||||
fOwner(NULL),
|
||||
fHasClientReference(false)
|
||||
{
|
||||
fToken = gTokenSpace.NewToken(kPictureToken, this);
|
||||
|
||||
@@ -826,7 +828,8 @@ ServerPicture::ServerPicture(const char* fileName, int32 offset)
|
||||
fData(NULL),
|
||||
fPictures(NULL),
|
||||
fUsurped(NULL),
|
||||
fOwner(NULL)
|
||||
fOwner(NULL),
|
||||
fHasClientReference(true)
|
||||
{
|
||||
fToken = gTokenSpace.NewToken(kPictureToken, this);
|
||||
|
||||
@@ -877,6 +880,18 @@ ServerPicture::SetOwner(ServerApp* owner)
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
ServerPicture::ReleaseClientReference()
|
||||
{
|
||||
if (!fHasClientReference)
|
||||
return false;
|
||||
|
||||
fHasClientReference = false;
|
||||
ReleaseReference();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ServerPicture::EnterStateChange()
|
||||
{
|
||||
|
||||
@@ -39,6 +39,8 @@ public:
|
||||
int32 Token() { return fToken; }
|
||||
bool SetOwner(ServerApp* owner);
|
||||
|
||||
bool ReleaseClientReference();
|
||||
|
||||
void EnterStateChange();
|
||||
void ExitStateChange();
|
||||
|
||||
@@ -69,6 +71,7 @@ private:
|
||||
PictureList* fPictures;
|
||||
ServerPicture* fUsurped;
|
||||
ServerApp* fOwner;
|
||||
bool fHasClientReference;
|
||||
};
|
||||
|
||||
#endif // SERVER_PICTURE_H
|
||||
|
||||
Reference in New Issue
Block a user