* Always make sure the reference to the bitmap is actually released. This

should fix bug #6824.
* Don't queue more pictures if we can only use a single CPU, and the queue is
  already busy.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39486 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2010-11-18 16:48:14 +00:00
parent 8446b330bc
commit df942b3eb1
2 changed files with 20 additions and 8 deletions
+12 -8
View File
@@ -95,10 +95,11 @@ ImageCache::RetrieveImage(const entry_ref& ref, int32 page,
QueueEntry* entry;
if (findQueue == fQueueMap.end()) {
if (target == NULL && fCacheMap.size() < 5
&& fBytes > fMaxBytes * 1 / 2) {
if (target == NULL
&& ((fCacheMap.size() < 5 && fBytes > fMaxBytes * 1 / 2)
|| (fMaxThreadCount == 1 && fQueueMap.size() > 1))) {
// Don't accept any further precaching if we're low on memory
// anyway.
// anyway, or if there is already a busy queue.
return B_NO_MEMORY;
}
@@ -290,7 +291,10 @@ ImageCache::_NotifyListeners(CacheEntry* entry, QueueEntry* queueEntry)
std::set<BMessenger>::iterator iterator = queueEntry->listeners.begin();
for (; iterator != queueEntry->listeners.end(); iterator++) {
iterator->SendMessage(&notification);
if (iterator->SendMessage(&notification) == B_OK) {
entry->bitmapOwner->AcquireReference();
// this is the reference owned by the target
}
}
}
@@ -304,7 +308,10 @@ ImageCache::_NotifyTarget(CacheEntry* entry, const BMessenger* target)
BMessage notification(kMsgImageCacheImageLoaded);
_BuildNotification(entry, notification);
target->SendMessage(&notification);
if (target->SendMessage(&notification) == B_OK) {
entry->bitmapOwner->AcquireReference();
// this is the reference owned by the target
}
}
@@ -314,9 +321,6 @@ ImageCache::_BuildNotification(CacheEntry* entry, BMessage& message)
if (entry == NULL)
return;
entry->bitmapOwner->AcquireReference();
// this is the reference owned by the target
message.AddString("type", entry->type);
message.AddString("mime", entry->mimeType);
message.AddRef("ref", &entry->ref);
+8
View File
@@ -521,16 +521,24 @@ ShowImageWindow::MessageReceived(BMessage* message)
{
fProgressWindow->Stop();
BitmapOwner* bitmapOwner = NULL;
message->FindPointer("bitmapOwner", (void**)&bitmapOwner);
bool first = fImageView->Bitmap() == NULL;
entry_ref ref;
message->FindRef("ref", &ref);
if (!first && ref != fNavigator.CurrentRef()) {
// ignore older images
if (bitmapOwner != NULL)
bitmapOwner->ReleaseReference();
break;
}
status_t status = fImageView->SetImage(message);
if (status != B_OK) {
if (bitmapOwner != NULL)
bitmapOwner->ReleaseReference();
_LoadError(ref);
// quit if file could not be opened