* 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(),
|
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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
@@ -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()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user