Ensure that LayoutItem::setParent resets the parents layout if we are currently its layout and release managed items.
RB:89 svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=773471
This commit is contained in:
parent
a7ccf41c3e
commit
9335a50776
@ -56,10 +56,7 @@ BorderLayout::BorderLayout(LayoutItem * parent) :
|
||||
|
||||
BorderLayout::~BorderLayout()
|
||||
{
|
||||
foreach (Plasma::LayoutItem *item, d->itemPositions) {
|
||||
item->unsetManagingLayout(this);
|
||||
}
|
||||
|
||||
releaseManagedItems();
|
||||
delete d;
|
||||
}
|
||||
|
||||
@ -117,6 +114,13 @@ void BorderLayout::relayout()
|
||||
}
|
||||
}
|
||||
|
||||
void BorderLayout::releaseManagedItems()
|
||||
{
|
||||
foreach (Plasma::LayoutItem *item, d->itemPositions) {
|
||||
item->unsetManagingLayout(this);
|
||||
}
|
||||
}
|
||||
|
||||
QSizeF BorderLayout::sizeHint() const
|
||||
{
|
||||
qreal hintHeight = 0.0;
|
||||
|
@ -86,6 +86,7 @@ public:
|
||||
|
||||
protected:
|
||||
void relayout();
|
||||
void releaseManagedItems();
|
||||
|
||||
private:
|
||||
class Private;
|
||||
|
@ -297,9 +297,7 @@ BoxLayout::Direction BoxLayout::direction() const
|
||||
|
||||
BoxLayout::~BoxLayout()
|
||||
{
|
||||
foreach (LayoutItem* item, d->children) {
|
||||
item->unsetManagingLayout(this);
|
||||
}
|
||||
releaseManagedItems();
|
||||
delete d;
|
||||
}
|
||||
|
||||
@ -532,6 +530,12 @@ void BoxLayout::relayout()
|
||||
startAnimation();
|
||||
}
|
||||
|
||||
void BoxLayout::releaseManagedItems()
|
||||
{
|
||||
foreach (LayoutItem* item, d->children) {
|
||||
item->unsetManagingLayout(this);
|
||||
}
|
||||
}
|
||||
|
||||
QSizeF BoxLayout::maximumSize() const
|
||||
{
|
||||
|
@ -89,6 +89,7 @@ class PLASMA_EXPORT BoxLayout : public Layout
|
||||
|
||||
protected:
|
||||
void relayout();
|
||||
void releaseManagedItems();
|
||||
|
||||
private:
|
||||
class Private;
|
||||
|
@ -46,12 +46,10 @@ FlowLayout::FlowLayout(LayoutItem* parent)
|
||||
, d(new Private)
|
||||
{
|
||||
}
|
||||
|
||||
FlowLayout::~FlowLayout()
|
||||
{
|
||||
foreach (LayoutItem *item, d->items) {
|
||||
item->unsetManagingLayout(this);
|
||||
}
|
||||
|
||||
releaseManagedItems();
|
||||
delete d;
|
||||
}
|
||||
|
||||
@ -254,6 +252,13 @@ void FlowLayout::relayout()
|
||||
startAnimation();
|
||||
}
|
||||
|
||||
void FlowLayout::releaseManagedItems()
|
||||
{
|
||||
foreach (LayoutItem *item, d->items) {
|
||||
item->unsetManagingLayout(this);
|
||||
}
|
||||
}
|
||||
|
||||
Qt::Orientations FlowLayout::expandingDirections() const
|
||||
{
|
||||
return Qt::Vertical | Qt::Horizontal;
|
||||
|
@ -53,6 +53,7 @@ public:
|
||||
|
||||
protected:
|
||||
void relayout();
|
||||
void releaseManagedItems();
|
||||
|
||||
private:
|
||||
class Private;
|
||||
|
@ -41,10 +41,7 @@ FreeLayout::FreeLayout(LayoutItem *parent)
|
||||
|
||||
FreeLayout::~FreeLayout()
|
||||
{
|
||||
foreach (LayoutItem *item, d->children) {
|
||||
item->unsetManagingLayout(this);
|
||||
}
|
||||
|
||||
releaseManagedItems();
|
||||
delete d;
|
||||
}
|
||||
|
||||
@ -103,6 +100,13 @@ void FreeLayout::relayout()
|
||||
}
|
||||
}
|
||||
|
||||
void FreeLayout::releaseManagedItems()
|
||||
{
|
||||
foreach (LayoutItem *item, d->children) {
|
||||
item->unsetManagingLayout(this);
|
||||
}
|
||||
}
|
||||
|
||||
QRectF FreeLayout::geometry() const
|
||||
{
|
||||
if (parent()) {
|
||||
|
@ -60,6 +60,7 @@ class PLASMA_EXPORT FreeLayout : public Layout
|
||||
|
||||
protected:
|
||||
void relayout();
|
||||
void releaseManagedItems();
|
||||
|
||||
private:
|
||||
class Private;
|
||||
|
@ -36,13 +36,13 @@ namespace Plasma
|
||||
class Layout::Private
|
||||
{
|
||||
public:
|
||||
Private(LayoutItem* p)
|
||||
Private()
|
||||
: leftMargin(12.0),
|
||||
rightMargin(12.0),
|
||||
topMargin(12.0),
|
||||
bottomMargin(12.0),
|
||||
spacing(6.0),
|
||||
parent(p),
|
||||
parent(0),
|
||||
animator(0),
|
||||
relayouting(false)
|
||||
{
|
||||
@ -66,13 +66,22 @@ class Layout::Private
|
||||
|
||||
Layout::Layout(LayoutItem *parent)
|
||||
: LayoutItem(),
|
||||
d(new Private(parent))
|
||||
d(new Private)
|
||||
{
|
||||
setParent(parent);
|
||||
}
|
||||
|
||||
void Layout::setParent(LayoutItem *parent)
|
||||
{
|
||||
if (d->parent == parent) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (d->parent && d->parent->layout() == this) {
|
||||
d->parent->unsetLayout();
|
||||
releaseManagedItems();
|
||||
}
|
||||
|
||||
d->parent = parent;
|
||||
|
||||
if (parent && parent->layout() != this) {
|
||||
@ -84,6 +93,7 @@ Layout::~Layout()
|
||||
{
|
||||
if (d->parent) {
|
||||
d->parent->unsetLayout();
|
||||
d->parent = 0;
|
||||
}
|
||||
|
||||
delete d;
|
||||
|
@ -175,6 +175,12 @@ class PLASMA_EXPORT Layout : public LayoutItem
|
||||
*/
|
||||
virtual void relayout() = 0;
|
||||
|
||||
/**
|
||||
* When called, the layout must cease management of any
|
||||
* current LayoutItems it is managing.
|
||||
*/
|
||||
virtual void releaseManagedItems() = 0;
|
||||
|
||||
/**
|
||||
* Starts a layout animation. Subclasses may call this
|
||||
* at the end of their relayout() implementation to
|
||||
|
@ -163,10 +163,7 @@ NodeLayout::NodeLayout(LayoutItem * parent)
|
||||
|
||||
NodeLayout::~NodeLayout()
|
||||
{
|
||||
foreach (LayoutItem * item, d->items.keys()) {
|
||||
item->unsetManagingLayout(this);
|
||||
}
|
||||
|
||||
releaseManagedItems();
|
||||
delete d;
|
||||
}
|
||||
|
||||
@ -184,6 +181,13 @@ void NodeLayout::relayout()
|
||||
}
|
||||
}
|
||||
|
||||
void NodeLayout::releaseManagedItems()
|
||||
{
|
||||
foreach (LayoutItem * item, d->items.keys()) {
|
||||
item->unsetManagingLayout(this);
|
||||
}
|
||||
}
|
||||
|
||||
QSizeF NodeLayout::sizeHint() const
|
||||
{
|
||||
return d->sizeHint;
|
||||
|
@ -108,6 +108,7 @@ public:
|
||||
|
||||
protected:
|
||||
void relayout();
|
||||
void releaseManagedItems();
|
||||
|
||||
private:
|
||||
class Private;
|
||||
|
Loading…
x
Reference in New Issue
Block a user