hrev50449 adds 3 changesets to branch 'master'
old head: af3057423c2951d7a1652cf7383b2fafe12872b6
new head: 871a4f63c718bfe49fbb354a0bb1e46716be5a46
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=871a4f63c718+%5Eaf3057423c29
----------------------------------------------------------------------------
df8d92af250b: Minor cleanup.
6331a6bd91b8: app_server: The client memory allocator is now reference counted.
* Not sure if cursors could also have triggered this, but the memory
allocator can now outlive its ServerApp.
* However, this may also reveal cases of memory that is not freed
correctly.
871a4f63c718: app_server: Fixed crash if there is no window.
[ Axel Dörfler <axeld@xxxxxxxxxxxxxxxx> ]
----------------------------------------------------------------------------
6 files changed, 26 insertions(+), 16 deletions(-)
src/servers/app/ClientMemoryAllocator.cpp | 5 +++++
src/servers/app/ClientMemoryAllocator.h | 3 ++-
src/servers/app/Desktop.cpp | 6 +++---
src/servers/app/ServerApp.cpp | 9 +++++----
src/servers/app/ServerApp.h | 6 ++++--
src/servers/app/Workspace.h | 13 +++++++------
############################################################################
Commit: df8d92af250b142669a620c463393a66d596a810
URL: http://cgit.haiku-os.org/haiku/commit/?id=df8d92af250b
Author: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date: Thu Feb 28 22:31:52 2013 UTC
Minor cleanup.
----------------------------------------------------------------------------
diff --git a/src/servers/app/Workspace.h b/src/servers/app/Workspace.h
index 7e0bfe9..e92db6c 100644
--- a/src/servers/app/Workspace.h
+++ b/src/servers/app/Workspace.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2009, Haiku.
+ * Copyright 2005-2013, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -15,11 +15,11 @@
class Desktop;
class Window;
-/*!
-Workspace objects are intended to be short-lived. You create them while
-already holding a lock to the Desktop read-write lock and then you can use them
-to query information, and then you destroy them again, for example by letting
-them go out of scope.
+
+/*! Workspace objects are intended to be short-lived. You create them while
+ already holding a lock to the Desktop read-write lock and then you can
use
+ them to query information, and then you destroy them again, for example
by
+ letting them go out of scope.
*/
class Workspace {
public:
@@ -48,4 +48,5 @@ private:
bool fCurrentWorkspace;
};
+
#endif /* WORKSPACE_H */
############################################################################
Commit: 6331a6bd91b83ec4855335a0da830fd6638c824d
URL: http://cgit.haiku-os.org/haiku/commit/?id=6331a6bd91b8
Author: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date: Sat Mar 9 11:54:02 2013 UTC
app_server: The client memory allocator is now reference counted.
* Not sure if cursors could also have triggered this, but the memory
allocator can now outlive its ServerApp.
* However, this may also reveal cases of memory that is not freed
correctly.
----------------------------------------------------------------------------
diff --git a/src/servers/app/ClientMemoryAllocator.cpp
b/src/servers/app/ClientMemoryAllocator.cpp
index f9ec018..0693ce8 100644
--- a/src/servers/app/ClientMemoryAllocator.cpp
+++ b/src/servers/app/ClientMemoryAllocator.cpp
@@ -316,6 +316,7 @@ ClientMemoryAllocator::_AllocateChunk(size_t size, bool&
newArea)
ClientMemory::ClientMemory()
:
+ fAllocator(NULL),
fBlock(NULL)
{
}
@@ -325,6 +326,8 @@ ClientMemory::~ClientMemory()
{
if (fBlock != NULL)
fAllocator->Free(fBlock);
+ if (fAllocator != NULL)
+ fAllocator->ReleaseReference();
}
@@ -333,6 +336,8 @@ ClientMemory::Allocate(ClientMemoryAllocator* allocator,
size_t size,
bool& newArea)
{
fAllocator = allocator;
+ fAllocator->AcquireReference();
+
return fAllocator->Allocate(size, &fBlock, newArea);
}
diff --git a/src/servers/app/ClientMemoryAllocator.h
b/src/servers/app/ClientMemoryAllocator.h
index 05ab8df..283ab8d 100644
--- a/src/servers/app/ClientMemoryAllocator.h
+++ b/src/servers/app/ClientMemoryAllocator.h
@@ -10,6 +10,7 @@
#include <Locker.h>
+#include <Referenceable.h>
#include <util/DoublyLinkedList.h>
@@ -34,7 +35,7 @@ typedef DoublyLinkedList<block> block_list;
typedef DoublyLinkedList<chunk> chunk_list;
-class ClientMemoryAllocator {
+class ClientMemoryAllocator : public BReferenceable {
public:
ClientMemoryAllocator(ServerApp* application);
~ClientMemoryAllocator();
diff --git a/src/servers/app/ServerApp.cpp b/src/servers/app/ServerApp.cpp
index ec6432a..af929c9 100644
--- a/src/servers/app/ServerApp.cpp
+++ b/src/servers/app/ServerApp.cpp
@@ -105,7 +105,7 @@ ServerApp::ServerApp(Desktop* desktop, port_id
clientReplyPort,
fViewCursor(NULL),
fCursorHideLevel(0),
fIsActive(false),
- fMemoryAllocator(this)
+ fMemoryAllocator(new ClientMemoryAllocator(this))
{
if (fSignature == "")
fSignature = "application/no-signature";
@@ -194,7 +194,7 @@ ServerApp::~ServerApp()
fWindowListLock.Lock();
}
- fMemoryAllocator.Detach();
+ fMemoryAllocator->Detach();
fMapLocker.Lock();
while (!fBitmapMap.empty())
@@ -204,6 +204,7 @@ ServerApp::~ServerApp()
fPictureMap.begin()->second->SetOwner(NULL);
fDesktop->GetCursorManager().DeleteCursors(fClientTeam);
+ fMemoryAllocator->ReleaseReference();
STRACE(("ServerApp %s::~ServerApp(): Exiting\n", Signature()));
}
@@ -565,7 +566,7 @@ ServerApp::_DispatchMessage(int32 code,
BPrivate::LinkReceiver& link)
break;
case AS_DUMP_ALLOCATOR:
- fMemoryAllocator.Dump();
+ fMemoryAllocator->Dump();
break;
case AS_DUMP_BITMAPS:
{
@@ -727,7 +728,7 @@ ServerApp::_DispatchMessage(int32 code,
BPrivate::LinkReceiver& link)
if (link.Read<int32>(&screenID) == B_OK) {
// TODO: choose the right HWInterface with
regards to the
// screenID
- bitmap =
gBitmapManager->CreateBitmap(&fMemoryAllocator,
+ bitmap =
gBitmapManager->CreateBitmap(fMemoryAllocator,
*fDesktop->HWInterface(), frame,
colorSpace, flags,
bytesPerRow, screenID,
&allocationFlags);
}
diff --git a/src/servers/app/ServerApp.h b/src/servers/app/ServerApp.h
index 84c88af..433ea47 100644
--- a/src/servers/app/ServerApp.h
+++ b/src/servers/app/ServerApp.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2012, Haiku.
+ * Copyright 2001-2013, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -38,6 +38,7 @@ namespace BPrivate {
class PortLink;
};
+
class ServerApp : public MessageLooper {
public:
ServerApp(Desktop* desktop,
@@ -156,7 +157,8 @@ private:
bool fIsActive;
- ClientMemoryAllocator fMemoryAllocator;
+ ClientMemoryAllocator* fMemoryAllocator;
};
+
#endif // SERVER_APP_H
############################################################################
Revision: hrev50449
Commit: 871a4f63c718bfe49fbb354a0bb1e46716be5a46
URL: http://cgit.haiku-os.org/haiku/commit/?id=871a4f63c718
Author: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date: Sat Mar 9 14:46:09 2013 UTC
app_server: Fixed crash if there is no window.
----------------------------------------------------------------------------
diff --git a/src/servers/app/Desktop.cpp b/src/servers/app/Desktop.cpp
index a5644d7..34157c1 100644
--- a/src/servers/app/Desktop.cpp
+++ b/src/servers/app/Desktop.cpp
@@ -1592,7 +1592,7 @@ Desktop::SetWindowWorkspaces(Window* window, uint32
workspaces)
/*! \brief Adds the window to the desktop.
- At this point, the window is still hidden and must be shown explicetly
+ At this point, the window is still hidden and must be shown explicitly
via ShowWindow().
*/
void
@@ -2117,7 +2117,7 @@ Desktop::RedrawBackground()
BRegion redraw;
Window* window = CurrentWindows().FirstWindow();
- if (window->Feel() == kDesktopWindowFeel) {
+ if (window != NULL && window->Feel() == kDesktopWindowFeel) {
redraw = window->VisibleContentRegion();
// look for desktop background view, and update its background
color
@@ -2126,7 +2126,7 @@ Desktop::RedrawBackground()
if (view != NULL)
view = view->FirstChild();
- while (view) {
+ while (view != NULL) {
if (view->IsDesktopBackground()) {
view->SetViewColor(fWorkspaces[fCurrentWorkspace].Color());
break;