* 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:
Axel Dörfler
2009-11-19 10:42:19 +00:00
parent 25fcb499b4
commit afad65b245
5 changed files with 42 additions and 7 deletions
+2 -2
View File
@@ -784,7 +784,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
STRACE(("ServerApp %s: Deleting Bitmap %ld\n", Signature(), STRACE(("ServerApp %s: Deleting Bitmap %ld\n", Signature(),
token)); token));
bitmap->ReleaseReference(); bitmap->ReleaseClientReference();
} }
fMapLocker.Unlock(); fMapLocker.Unlock();
@@ -872,7 +872,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
ServerPicture* picture = _FindPicture(token); ServerPicture* picture = _FindPicture(token);
if (picture != NULL) if (picture != NULL)
picture->ReleaseReference(); picture->ReleaseClientReference();
} }
break; break;
} }
+16 -2
View File
@@ -75,7 +75,8 @@ ServerBitmap::ServerBitmap(BRect rect, color_space space, uint32 flags,
fBytesPerRow(0), fBytesPerRow(0),
fSpace(space), fSpace(space),
fFlags(flags), fFlags(flags),
fOwner(NULL) fOwner(NULL),
fHasClientReference(true)
// fToken is initialized (if used) by the BitmapManager // fToken is initialized (if used) by the BitmapManager
{ {
int32 minBytesPerRow = get_bytes_per_row(space, fWidth); int32 minBytesPerRow = get_bytes_per_row(space, fWidth);
@@ -91,7 +92,8 @@ ServerBitmap::ServerBitmap(const ServerBitmap* bitmap)
fAllocationCookie(NULL), fAllocationCookie(NULL),
fOverlay(NULL), fOverlay(NULL),
fBuffer(NULL), fBuffer(NULL),
fReferenceCount(1) fReferenceCount(1),
fHasClientReference(false)
{ {
if (bitmap) { if (bitmap) {
fWidth = bitmap->fWidth; fWidth = bitmap->fWidth;
@@ -220,6 +222,18 @@ ServerBitmap::Owner() const
} }
bool
ServerBitmap::ReleaseClientReference()
{
if (!fHasClientReference)
return false;
fHasClientReference = false;
ReleaseReference();
return true;
}
void void
ServerBitmap::PrintToStream() ServerBitmap::PrintToStream()
{ {
+3
View File
@@ -72,6 +72,8 @@ public:
bool SetOwner(ServerApp* owner); bool SetOwner(ServerApp* owner);
ServerApp* Owner() const; ServerApp* Owner() const;
bool ReleaseClientReference();
//! Does a shallow copy of the bitmap passed to it //! Does a shallow copy of the bitmap passed to it
inline void ShallowCopy(const ServerBitmap *from); inline void ShallowCopy(const ServerBitmap *from);
@@ -112,6 +114,7 @@ protected:
ServerApp* fOwner; ServerApp* fOwner;
int32 fToken; int32 fToken;
bool fHasClientReference;
}; };
class UtilityBitmap : public ServerBitmap { class UtilityBitmap : public ServerBitmap {
+18 -3
View File
@@ -784,7 +784,8 @@ ServerPicture::ServerPicture()
fFile(NULL), fFile(NULL),
fPictures(NULL), fPictures(NULL),
fUsurped(NULL), fUsurped(NULL),
fOwner(NULL) fOwner(NULL),
fHasClientReference(true)
{ {
fToken = gTokenSpace.NewToken(kPictureToken, this); fToken = gTokenSpace.NewToken(kPictureToken, this);
fData = new(std::nothrow) BMallocIO(); fData = new(std::nothrow) BMallocIO();
@@ -799,7 +800,8 @@ ServerPicture::ServerPicture(const ServerPicture& picture)
fData(NULL), fData(NULL),
fPictures(NULL), fPictures(NULL),
fUsurped(NULL), fUsurped(NULL),
fOwner(NULL) fOwner(NULL),
fHasClientReference(false)
{ {
fToken = gTokenSpace.NewToken(kPictureToken, this); fToken = gTokenSpace.NewToken(kPictureToken, this);
@@ -826,7 +828,8 @@ ServerPicture::ServerPicture(const char* fileName, int32 offset)
fData(NULL), fData(NULL),
fPictures(NULL), fPictures(NULL),
fUsurped(NULL), fUsurped(NULL),
fOwner(NULL) fOwner(NULL),
fHasClientReference(true)
{ {
fToken = gTokenSpace.NewToken(kPictureToken, this); 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 void
ServerPicture::EnterStateChange() ServerPicture::EnterStateChange()
{ {
+3
View File
@@ -39,6 +39,8 @@ public:
int32 Token() { return fToken; } int32 Token() { return fToken; }
bool SetOwner(ServerApp* owner); bool SetOwner(ServerApp* owner);
bool ReleaseClientReference();
void EnterStateChange(); void EnterStateChange();
void ExitStateChange(); void ExitStateChange();
@@ -69,6 +71,7 @@ private:
PictureList* fPictures; PictureList* fPictures;
ServerPicture* fUsurped; ServerPicture* fUsurped;
ServerApp* fOwner; ServerApp* fOwner;
bool fHasClientReference;
}; };
#endif // SERVER_PICTURE_H #endif // SERVER_PICTURE_H