system_colors() expects a colormap to be permanently stored within libbe, so we never delete the BPrivateScreen object
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13071 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -24,7 +24,6 @@
|
|||||||
// Description: BPrivateScreen is the class which does the real work
|
// Description: BPrivateScreen is the class which does the real work
|
||||||
// for the proxy class BScreen (it interacts with the app server).
|
// for the proxy class BScreen (it interacts with the app server).
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
#include <Debug.h>
|
|
||||||
#include <Locker.h>
|
#include <Locker.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
@@ -46,7 +45,6 @@ struct screen_desc {
|
|||||||
|
|
||||||
|
|
||||||
static BPrivateScreen *sScreen;
|
static BPrivateScreen *sScreen;
|
||||||
static int32 sScreenRefCount;
|
|
||||||
|
|
||||||
// used to synchronize creation/deletion of the sScreen object
|
// used to synchronize creation/deletion of the sScreen object
|
||||||
static BLocker sScreenLock("screen lock");
|
static BLocker sScreenLock("screen lock");
|
||||||
@@ -59,10 +57,9 @@ BPrivateScreen::CheckOut(BWindow *win)
|
|||||||
{
|
{
|
||||||
sScreenLock.Lock();
|
sScreenLock.Lock();
|
||||||
|
|
||||||
if (atomic_add(&sScreenRefCount, 1) == 0) {
|
if (sScreen == NULL) {
|
||||||
// TODO: If we start supporting multiple monitors, we
|
// TODO: If we start supporting multiple monitors, we
|
||||||
// should return the right screen for the passed BWindow
|
// should return the right screen for the passed BWindow
|
||||||
ASSERT(sScreen == NULL);
|
|
||||||
sScreen = new BPrivateScreen();
|
sScreen = new BPrivateScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,10 +74,9 @@ BPrivateScreen::CheckOut(screen_id id)
|
|||||||
{
|
{
|
||||||
sScreenLock.Lock();
|
sScreenLock.Lock();
|
||||||
|
|
||||||
if (atomic_add(&sScreenRefCount, 1) == 0) {
|
if (sScreen == NULL) {
|
||||||
// TODO: If we start supporting multiple monitors, we
|
// TODO: If we start supporting multiple monitors, we
|
||||||
// should return the right object for the given screen_id
|
// should return the right object for the given screen_id
|
||||||
ASSERT(sScreen == NULL);
|
|
||||||
sScreen = new BPrivateScreen();
|
sScreen = new BPrivateScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,18 +89,9 @@ BPrivateScreen::CheckOut(screen_id id)
|
|||||||
void
|
void
|
||||||
BPrivateScreen::Return(BPrivateScreen *screen)
|
BPrivateScreen::Return(BPrivateScreen *screen)
|
||||||
{
|
{
|
||||||
sScreenLock.Lock();
|
// Never delete the sScreen object.
|
||||||
|
// system_colors() expects the colormap to be
|
||||||
if (atomic_add(&sScreenRefCount, -1) == 1) {
|
// permanently stored within libbe.
|
||||||
// TODO: Check if the passed object is the same we are deleting
|
|
||||||
// here. Not much important for now though, since we only have one.
|
|
||||||
// TODO: We could avoid these lines, and just let the object live
|
|
||||||
// until the death of the application.
|
|
||||||
delete sScreen;
|
|
||||||
sScreen = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
sScreenLock.Unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user