* 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:
Axel Dörfler 2008-10-15 14:45:51 +00:00
parent 08a6ab444b
commit 4a29c739af
2 changed files with 18 additions and 3 deletions

View File

@ -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
PairsView::_ReadRandomIcons()
{
@ -125,10 +140,9 @@ PairsView::_ReadRandomIcons()
delete[] data;
if (!bitmaps.AddItem(bitmap))
if (_HasBitmap(bitmaps, bitmap) || !bitmaps.AddItem(bitmap))
delete bitmap;
if (bitmaps.CountItems() >= 128) {
else if (bitmaps.CountItems() >= 128) {
// this is enough to choose from, stop eating memory...
break;
}

View File

@ -28,6 +28,7 @@ private:
void _SetPairsBoard();
void _ReadRandomIcons();
void _GenerateCardPos();
bool _HasBitmap(BList& bitmaps, BBitmap* bitmap);
BMessage* fButtonMessage;
BBitmap* fCard[8];