* 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:
@@ -95,10 +95,11 @@ ImageCache::RetrieveImage(const entry_ref& ref, int32 page,
|
|||||||
QueueEntry* entry;
|
QueueEntry* entry;
|
||||||
|
|
||||||
if (findQueue == fQueueMap.end()) {
|
if (findQueue == fQueueMap.end()) {
|
||||||
if (target == NULL && fCacheMap.size() < 5
|
if (target == NULL
|
||||||
&& fBytes > fMaxBytes * 1 / 2) {
|
&& ((fCacheMap.size() < 5 && fBytes > fMaxBytes * 1 / 2)
|
||||||
|
|| (fMaxThreadCount == 1 && fQueueMap.size() > 1))) {
|
||||||
// Don't accept any further precaching if we're low on memory
|
// 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;
|
return B_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,7 +291,10 @@ ImageCache::_NotifyListeners(CacheEntry* entry, QueueEntry* queueEntry)
|
|||||||
|
|
||||||
std::set<BMessenger>::iterator iterator = queueEntry->listeners.begin();
|
std::set<BMessenger>::iterator iterator = queueEntry->listeners.begin();
|
||||||
for (; iterator != queueEntry->listeners.end(); iterator++) {
|
for (; iterator != queueEntry->listeners.end(); iterator++) {
|
||||||
iterator->SendMessage(¬ification);
|
if (iterator->SendMessage(¬ification) == 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);
|
BMessage notification(kMsgImageCacheImageLoaded);
|
||||||
_BuildNotification(entry, notification);
|
_BuildNotification(entry, notification);
|
||||||
|
|
||||||
target->SendMessage(¬ification);
|
if (target->SendMessage(¬ification) == 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)
|
if (entry == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
entry->bitmapOwner->AcquireReference();
|
|
||||||
// this is the reference owned by the target
|
|
||||||
|
|
||||||
message.AddString("type", entry->type);
|
message.AddString("type", entry->type);
|
||||||
message.AddString("mime", entry->mimeType);
|
message.AddString("mime", entry->mimeType);
|
||||||
message.AddRef("ref", &entry->ref);
|
message.AddRef("ref", &entry->ref);
|
||||||
|
|||||||
@@ -521,16 +521,24 @@ ShowImageWindow::MessageReceived(BMessage* message)
|
|||||||
{
|
{
|
||||||
fProgressWindow->Stop();
|
fProgressWindow->Stop();
|
||||||
|
|
||||||
|
BitmapOwner* bitmapOwner = NULL;
|
||||||
|
message->FindPointer("bitmapOwner", (void**)&bitmapOwner);
|
||||||
|
|
||||||
bool first = fImageView->Bitmap() == NULL;
|
bool first = fImageView->Bitmap() == NULL;
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
message->FindRef("ref", &ref);
|
message->FindRef("ref", &ref);
|
||||||
if (!first && ref != fNavigator.CurrentRef()) {
|
if (!first && ref != fNavigator.CurrentRef()) {
|
||||||
// ignore older images
|
// ignore older images
|
||||||
|
if (bitmapOwner != NULL)
|
||||||
|
bitmapOwner->ReleaseReference();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t status = fImageView->SetImage(message);
|
status_t status = fImageView->SetImage(message);
|
||||||
if (status != B_OK) {
|
if (status != B_OK) {
|
||||||
|
if (bitmapOwner != NULL)
|
||||||
|
bitmapOwner->ReleaseReference();
|
||||||
|
|
||||||
_LoadError(ref);
|
_LoadError(ref);
|
||||||
|
|
||||||
// quit if file could not be opened
|
// quit if file could not be opened
|
||||||
|
|||||||
Reference in New Issue
Block a user