Someone familiar with BBitmap, please review:
* BBitmap could leak fWindow in operator=() * two copy constructors didn't initialize the members properly, which could cause crashes in _CleanUp() * minor cleanup Actually found this while staring at CID 254-257, which were false alarm, though. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38246 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -224,6 +224,19 @@ BBitmap::BBitmap(const BBitmap* source, bool acceptsViews, bool needsContiguous)
|
|||||||
|
|
||||||
|
|
||||||
BBitmap::BBitmap(const BBitmap& source, uint32 flags)
|
BBitmap::BBitmap(const BBitmap& source, uint32 flags)
|
||||||
|
:
|
||||||
|
fBasePointer(NULL),
|
||||||
|
fSize(0),
|
||||||
|
fColorSpace(B_NO_COLOR_SPACE),
|
||||||
|
fBounds(0, 0, -1, -1),
|
||||||
|
fBytesPerRow(0),
|
||||||
|
fWindow(NULL),
|
||||||
|
fServerToken(-1),
|
||||||
|
fAreaOffset(-1),
|
||||||
|
fArea(-1),
|
||||||
|
fServerArea(-1),
|
||||||
|
fFlags(0),
|
||||||
|
fInitError(B_NO_INIT)
|
||||||
{
|
{
|
||||||
if (!source.IsValid())
|
if (!source.IsValid())
|
||||||
return;
|
return;
|
||||||
@@ -237,8 +250,20 @@ BBitmap::BBitmap(const BBitmap& source, uint32 flags)
|
|||||||
|
|
||||||
|
|
||||||
BBitmap::BBitmap(const BBitmap& source)
|
BBitmap::BBitmap(const BBitmap& source)
|
||||||
|
:
|
||||||
|
fBasePointer(NULL),
|
||||||
|
fSize(0),
|
||||||
|
fColorSpace(B_NO_COLOR_SPACE),
|
||||||
|
fBounds(0, 0, -1, -1),
|
||||||
|
fBytesPerRow(0),
|
||||||
|
fWindow(NULL),
|
||||||
|
fServerToken(-1),
|
||||||
|
fAreaOffset(-1),
|
||||||
|
fArea(-1),
|
||||||
|
fServerArea(-1),
|
||||||
|
fFlags(0),
|
||||||
|
fInitError(B_NO_INIT)
|
||||||
{
|
{
|
||||||
fBasePointer = NULL;
|
|
||||||
*this = source;
|
*this = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,8 +272,6 @@ BBitmap::BBitmap(const BBitmap& source)
|
|||||||
*/
|
*/
|
||||||
BBitmap::~BBitmap()
|
BBitmap::~BBitmap()
|
||||||
{
|
{
|
||||||
if (fWindow && fWindow->Lock())
|
|
||||||
delete fWindow;
|
|
||||||
_CleanUp();
|
_CleanUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1110,12 +1133,19 @@ BBitmap::_InitObject(BRect bounds, color_space colorSpace, uint32 flags,
|
|||||||
void
|
void
|
||||||
BBitmap::_CleanUp()
|
BBitmap::_CleanUp()
|
||||||
{
|
{
|
||||||
|
if (fWindow != NULL) {
|
||||||
|
if (fWindow->Lock())
|
||||||
|
delete fWindow;
|
||||||
|
fWindow = NULL;
|
||||||
|
// this will leak fWindow if it couldn't be locked
|
||||||
|
}
|
||||||
|
|
||||||
if (fBasePointer == NULL)
|
if (fBasePointer == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((fFlags & B_BITMAP_NO_SERVER_LINK) != 0) {
|
if ((fFlags & B_BITMAP_NO_SERVER_LINK) != 0) {
|
||||||
free(fBasePointer);
|
free(fBasePointer);
|
||||||
} else {
|
} else if (fServerToken != -1) {
|
||||||
BPrivate::AppServerLink link;
|
BPrivate::AppServerLink link;
|
||||||
// AS_DELETE_BITMAP:
|
// AS_DELETE_BITMAP:
|
||||||
// Attached Data:
|
// Attached Data:
|
||||||
|
|||||||
Reference in New Issue
Block a user