* The CompoundLayouters were leaked before. Made the class BReferenceable and
update references correctly. * LocalLayouter::SetCompoundLayouter(): Remove the local layouter from the previous compound layouter. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35983 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
9be3c0f4c6
commit
320a5686e4
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2006-2009, Ingo Weinhold <ingo_weinhold@gmx.de>.
|
||||
* Copyright 2006-2010, Ingo Weinhold <ingo_weinhold@gmx.de>.
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
@ -14,6 +14,8 @@
|
|||
#include <List.h>
|
||||
#include <View.h>
|
||||
|
||||
#include <Referenceable.h>
|
||||
|
||||
#include "ComplexLayouter.h"
|
||||
#include "OneElementLayouter.h"
|
||||
#include "SimpleLayouter.h"
|
||||
|
@ -50,7 +52,7 @@
|
|||
//#define DEBUG_LAYOUT
|
||||
|
||||
// CompoundLayouter
|
||||
class BTwoDimensionalLayout::CompoundLayouter {
|
||||
class BTwoDimensionalLayout::CompoundLayouter : public BReferenceable {
|
||||
public:
|
||||
CompoundLayouter(enum orientation orientation);
|
||||
virtual ~CompoundLayouter();
|
||||
|
@ -138,6 +140,7 @@ private:
|
|||
class BTwoDimensionalLayout::LocalLayouter : private BLayoutContextListener {
|
||||
public:
|
||||
LocalLayouter(BTwoDimensionalLayout* layout);
|
||||
~LocalLayouter();
|
||||
|
||||
// interface for the BTwoDimensionalLayout class
|
||||
|
||||
|
@ -891,6 +894,20 @@ BTwoDimensionalLayout::LocalLayouter::LocalLayouter(
|
|||
}
|
||||
|
||||
|
||||
BTwoDimensionalLayout::LocalLayouter::~LocalLayouter()
|
||||
{
|
||||
if (fHLayouter != NULL) {
|
||||
fHLayouter->RemoveLocalLayouter(this);
|
||||
fHLayouter->ReleaseReference();
|
||||
}
|
||||
|
||||
if (fVLayouter != NULL) {
|
||||
fVLayouter->RemoveLocalLayouter(this);
|
||||
fVLayouter->ReleaseReference();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BSize
|
||||
BTwoDimensionalLayout::LocalLayouter::MinSize()
|
||||
{
|
||||
|
@ -1146,10 +1163,25 @@ void
|
|||
BTwoDimensionalLayout::LocalLayouter::SetCompoundLayouter(
|
||||
CompoundLayouter* compoundLayouter, enum orientation orientation)
|
||||
{
|
||||
if (orientation == B_HORIZONTAL)
|
||||
CompoundLayouter* oldCompoundLayouter;
|
||||
if (orientation == B_HORIZONTAL) {
|
||||
oldCompoundLayouter = fHLayouter;
|
||||
fHLayouter = compoundLayouter;
|
||||
else
|
||||
} else {
|
||||
oldCompoundLayouter = fVLayouter;
|
||||
fVLayouter = (VerticalCompoundLayouter*)compoundLayouter;
|
||||
}
|
||||
|
||||
if (compoundLayouter == oldCompoundLayouter)
|
||||
return;
|
||||
|
||||
if (oldCompoundLayouter != NULL) {
|
||||
oldCompoundLayouter->RemoveLocalLayouter(this);
|
||||
oldCompoundLayouter->ReleaseReference();
|
||||
}
|
||||
|
||||
if (compoundLayouter != NULL)
|
||||
compoundLayouter->AcquireReference();
|
||||
|
||||
InternalInvalidateLayout(compoundLayouter);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue