* When adding new bitmaps, Pairs now checks if it already got it (in case two
apps are using the same icon). * This fixes bug #2694. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28133 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -69,6 +69,21 @@ PairsView::AttachedToWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
PairsView::_HasBitmap(BList& bitmaps, BBitmap* bitmap)
|
||||||
|
{
|
||||||
|
// TODO: if this takes too long, we could build a hash value for each
|
||||||
|
// bitmap in a separate list
|
||||||
|
for (int32 i = bitmaps.CountItems(); i-- > 0;) {
|
||||||
|
BBitmap* item = (BBitmap*)bitmaps.ItemAtFast(i);
|
||||||
|
if (!memcmp(item->Bits(), bitmap->Bits(), item->BitsLength()))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PairsView::_ReadRandomIcons()
|
PairsView::_ReadRandomIcons()
|
||||||
{
|
{
|
||||||
@@ -125,10 +140,9 @@ PairsView::_ReadRandomIcons()
|
|||||||
|
|
||||||
delete[] data;
|
delete[] data;
|
||||||
|
|
||||||
if (!bitmaps.AddItem(bitmap))
|
if (_HasBitmap(bitmaps, bitmap) || !bitmaps.AddItem(bitmap))
|
||||||
delete bitmap;
|
delete bitmap;
|
||||||
|
else if (bitmaps.CountItems() >= 128) {
|
||||||
if (bitmaps.CountItems() >= 128) {
|
|
||||||
// this is enough to choose from, stop eating memory...
|
// this is enough to choose from, stop eating memory...
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ private:
|
|||||||
void _SetPairsBoard();
|
void _SetPairsBoard();
|
||||||
void _ReadRandomIcons();
|
void _ReadRandomIcons();
|
||||||
void _GenerateCardPos();
|
void _GenerateCardPos();
|
||||||
|
bool _HasBitmap(BList& bitmaps, BBitmap* bitmap);
|
||||||
|
|
||||||
BMessage* fButtonMessage;
|
BMessage* fButtonMessage;
|
||||||
BBitmap* fCard[8];
|
BBitmap* fCard[8];
|
||||||
|
|||||||
Reference in New Issue
Block a user