* Deleted overlays were never removed from the fOverlays list, instead they were

added another time (copy&paste bug). This caused #3282.
* Added optional tracing output to Overlay.cpp.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32454 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-08-17 10:16:23 +00:00
parent abc73d0a65
commit 219bd33f29
2 changed files with 49 additions and 31 deletions
+7 -6
View File
@@ -8,8 +8,8 @@
*/ */
/*! /*!
Whenever a ServerBitmap associated with a client-side BBitmap needs to be Whenever a ServerBitmap associated with a client-side BBitmap needs to be
created or destroyed, the BitmapManager needs to handle it. It takes care of created or destroyed, the BitmapManager needs to handle it. It takes care of
all memory management related to them. all memory management related to them.
*/ */
@@ -209,7 +209,8 @@ void
BitmapManager::DeleteBitmap(ServerBitmap* bitmap) BitmapManager::DeleteBitmap(ServerBitmap* bitmap)
{ {
if (bitmap == NULL || !bitmap->_Release()) { if (bitmap == NULL || !bitmap->_Release()) {
// there are other references to this bitmap, we don't have to delete it yet // there are other references to this bitmap, we don't have to delete
// it yet
return; return;
} }
@@ -218,7 +219,7 @@ BitmapManager::DeleteBitmap(ServerBitmap* bitmap)
return; return;
if (bitmap->Overlay() != NULL) if (bitmap->Overlay() != NULL)
fOverlays.AddItem(bitmap); fOverlays.RemoveItem(bitmap);
if (fBitmapList.RemoveItem(bitmap)) if (fBitmapList.RemoveItem(bitmap))
delete bitmap; delete bitmap;
@@ -249,7 +250,7 @@ BitmapManager::SuspendOverlays()
for (int32 i = 0; i < fOverlays.CountItems(); i++) { for (int32 i = 0; i < fOverlays.CountItems(); i++) {
ServerBitmap* bitmap = (ServerBitmap*)fOverlays.ItemAt(i); ServerBitmap* bitmap = (ServerBitmap*)fOverlays.ItemAt(i);
bitmap->Overlay()->Suspend(bitmap, false); bitmap->Overlay()->Suspend(bitmap, false);
} }
} }
@@ -279,6 +280,6 @@ BitmapManager::ResumeOverlays()
ServerBitmap* bitmap = (ServerBitmap*)fOverlays.ItemAt(i); ServerBitmap* bitmap = (ServerBitmap*)fOverlays.ItemAt(i);
bitmap->Overlay()->Resume(bitmap); bitmap->Overlay()->Resume(bitmap);
} }
} }
+42 -25
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2006-2007, Haiku, Inc. * Copyright 2006-2009, Haiku, Inc.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -9,42 +9,49 @@
#include "Overlay.h" #include "Overlay.h"
#include <BitmapPrivate.h>
#include "HWInterface.h" #include "HWInterface.h"
#include "ServerBitmap.h" #include "ServerBitmap.h"
#include <BitmapPrivate.h>
//#define TRACE_OVERLAY
#ifdef TRACE_OVERLAY
# define TRACE(x...) ktrace_printf(x);
#else
# define TRACE(x...) ;
#endif
const static bigtime_t kOverlayTimeout = 1000000LL; const static bigtime_t kOverlayTimeout = 1000000LL;
// after 1 second, the team holding the lock will be killed // after 1 second, the team holding the lock will be killed
class SemaphoreLocker { class SemaphoreLocker {
public: public:
SemaphoreLocker(sem_id semaphore, SemaphoreLocker(sem_id semaphore, bigtime_t timeout = B_INFINITE_TIMEOUT)
bigtime_t timeout = B_INFINITE_TIMEOUT) :
: fSemaphore(semaphore) fSemaphore(semaphore)
{ {
do { do {
fStatus = acquire_sem_etc(fSemaphore, 1, B_RELATIVE_TIMEOUT, fStatus = acquire_sem_etc(fSemaphore, 1, B_RELATIVE_TIMEOUT,
timeout); timeout);
} while (fStatus == B_INTERRUPTED); } while (fStatus == B_INTERRUPTED);
} }
~SemaphoreLocker() ~SemaphoreLocker()
{ {
if (fStatus == B_OK) if (fStatus == B_OK)
release_sem_etc(fSemaphore, 1, B_DO_NOT_RESCHEDULE); release_sem_etc(fSemaphore, 1, B_DO_NOT_RESCHEDULE);
} }
status_t status_t LockStatus()
LockStatus() {
{ return fStatus;
return fStatus; }
}
private: private:
sem_id fSemaphore; sem_id fSemaphore;
status_t fStatus; status_t fStatus;
}; };
@@ -71,6 +78,8 @@ Overlay::Overlay(HWInterface& interface, ServerBitmap* bitmap,
fWindow.flags = B_OVERLAY_COLOR_KEY; fWindow.flags = B_OVERLAY_COLOR_KEY;
_AllocateBuffer(bitmap); _AllocateBuffer(bitmap);
TRACE("overlay: created %p, bitmap %p\n", this, bitmap);
} }
@@ -80,6 +89,7 @@ Overlay::~Overlay()
_FreeBuffer(); _FreeBuffer();
delete_sem(fSemaphore); delete_sem(fSemaphore);
TRACE("overlay: deleted %p\n", this);
} }
@@ -104,6 +114,8 @@ Overlay::Resume(ServerBitmap* bitmap)
// TODO: kill app! // TODO: kill app!
} }
TRACE("overlay: resume %p (lock status %ld)\n", this, locker.LockStatus());
status_t status = _AllocateBuffer(bitmap); status_t status = _AllocateBuffer(bitmap);
if (status < B_OK) if (status < B_OK)
return status; return status;
@@ -121,6 +133,8 @@ Overlay::Suspend(ServerBitmap* bitmap, bool needTemporary)
// TODO: kill app! // TODO: kill app!
} }
TRACE("overlay: suspend %p (lock status %ld)\n", this, locker.LockStatus());
_FreeBuffer(); _FreeBuffer();
fClientData->buffer = NULL; fClientData->buffer = NULL;
@@ -209,6 +223,7 @@ Overlay::Hide()
return; return;
fHWInterface.HideOverlay(this); fHWInterface.HideOverlay(this);
TRACE("overlay: hide %p\n", this);
} }
@@ -259,6 +274,8 @@ Overlay::Configure(const BRect& source, const BRect& destination)
return; return;
} }
TRACE("overlay: configure %p\n", this);
fView.h_start = (uint16)source.left; fView.h_start = (uint16)source.left;
fView.v_start = (uint16)source.top; fView.v_start = (uint16)source.top;
fView.width = (uint16)source.IntegerWidth() + 1; fView.width = (uint16)source.IntegerWidth() + 1;