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()
|
BorderLayout::~BorderLayout()
|
||||||
{
|
{
|
||||||
foreach (Plasma::LayoutItem *item, d->itemPositions) {
|
releaseManagedItems();
|
||||||
item->unsetManagingLayout(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete d;
|
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
|
QSizeF BorderLayout::sizeHint() const
|
||||||
{
|
{
|
||||||
qreal hintHeight = 0.0;
|
qreal hintHeight = 0.0;
|
||||||
|
@ -86,6 +86,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void relayout();
|
void relayout();
|
||||||
|
void releaseManagedItems();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Private;
|
class Private;
|
||||||
|
@ -297,9 +297,7 @@ BoxLayout::Direction BoxLayout::direction() const
|
|||||||
|
|
||||||
BoxLayout::~BoxLayout()
|
BoxLayout::~BoxLayout()
|
||||||
{
|
{
|
||||||
foreach (LayoutItem* item, d->children) {
|
releaseManagedItems();
|
||||||
item->unsetManagingLayout(this);
|
|
||||||
}
|
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -532,6 +530,12 @@ void BoxLayout::relayout()
|
|||||||
startAnimation();
|
startAnimation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BoxLayout::releaseManagedItems()
|
||||||
|
{
|
||||||
|
foreach (LayoutItem* item, d->children) {
|
||||||
|
item->unsetManagingLayout(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QSizeF BoxLayout::maximumSize() const
|
QSizeF BoxLayout::maximumSize() const
|
||||||
{
|
{
|
||||||
|
@ -89,6 +89,7 @@ class PLASMA_EXPORT BoxLayout : public Layout
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void relayout();
|
void relayout();
|
||||||
|
void releaseManagedItems();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Private;
|
class Private;
|
||||||
|
@ -46,12 +46,10 @@ FlowLayout::FlowLayout(LayoutItem* parent)
|
|||||||
, d(new Private)
|
, d(new Private)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
FlowLayout::~FlowLayout()
|
FlowLayout::~FlowLayout()
|
||||||
{
|
{
|
||||||
foreach (LayoutItem *item, d->items) {
|
releaseManagedItems();
|
||||||
item->unsetManagingLayout(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,6 +252,13 @@ void FlowLayout::relayout()
|
|||||||
startAnimation();
|
startAnimation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FlowLayout::releaseManagedItems()
|
||||||
|
{
|
||||||
|
foreach (LayoutItem *item, d->items) {
|
||||||
|
item->unsetManagingLayout(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Qt::Orientations FlowLayout::expandingDirections() const
|
Qt::Orientations FlowLayout::expandingDirections() const
|
||||||
{
|
{
|
||||||
return Qt::Vertical | Qt::Horizontal;
|
return Qt::Vertical | Qt::Horizontal;
|
||||||
|
@ -53,6 +53,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void relayout();
|
void relayout();
|
||||||
|
void releaseManagedItems();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Private;
|
class Private;
|
||||||
|
@ -41,10 +41,7 @@ FreeLayout::FreeLayout(LayoutItem *parent)
|
|||||||
|
|
||||||
FreeLayout::~FreeLayout()
|
FreeLayout::~FreeLayout()
|
||||||
{
|
{
|
||||||
foreach (LayoutItem *item, d->children) {
|
releaseManagedItems();
|
||||||
item->unsetManagingLayout(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,6 +100,13 @@ void FreeLayout::relayout()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FreeLayout::releaseManagedItems()
|
||||||
|
{
|
||||||
|
foreach (LayoutItem *item, d->children) {
|
||||||
|
item->unsetManagingLayout(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QRectF FreeLayout::geometry() const
|
QRectF FreeLayout::geometry() const
|
||||||
{
|
{
|
||||||
if (parent()) {
|
if (parent()) {
|
||||||
|
@ -60,6 +60,7 @@ class PLASMA_EXPORT FreeLayout : public Layout
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void relayout();
|
void relayout();
|
||||||
|
void releaseManagedItems();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Private;
|
class Private;
|
||||||
|
@ -36,13 +36,13 @@ namespace Plasma
|
|||||||
class Layout::Private
|
class Layout::Private
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Private(LayoutItem* p)
|
Private()
|
||||||
: leftMargin(12.0),
|
: leftMargin(12.0),
|
||||||
rightMargin(12.0),
|
rightMargin(12.0),
|
||||||
topMargin(12.0),
|
topMargin(12.0),
|
||||||
bottomMargin(12.0),
|
bottomMargin(12.0),
|
||||||
spacing(6.0),
|
spacing(6.0),
|
||||||
parent(p),
|
parent(0),
|
||||||
animator(0),
|
animator(0),
|
||||||
relayouting(false)
|
relayouting(false)
|
||||||
{
|
{
|
||||||
@ -66,13 +66,22 @@ class Layout::Private
|
|||||||
|
|
||||||
Layout::Layout(LayoutItem *parent)
|
Layout::Layout(LayoutItem *parent)
|
||||||
: LayoutItem(),
|
: LayoutItem(),
|
||||||
d(new Private(parent))
|
d(new Private)
|
||||||
{
|
{
|
||||||
setParent(parent);
|
setParent(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layout::setParent(LayoutItem *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;
|
d->parent = parent;
|
||||||
|
|
||||||
if (parent && parent->layout() != this) {
|
if (parent && parent->layout() != this) {
|
||||||
@ -84,6 +93,7 @@ Layout::~Layout()
|
|||||||
{
|
{
|
||||||
if (d->parent) {
|
if (d->parent) {
|
||||||
d->parent->unsetLayout();
|
d->parent->unsetLayout();
|
||||||
|
d->parent = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete d;
|
delete d;
|
||||||
|
@ -175,6 +175,12 @@ class PLASMA_EXPORT Layout : public LayoutItem
|
|||||||
*/
|
*/
|
||||||
virtual void relayout() = 0;
|
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
|
* Starts a layout animation. Subclasses may call this
|
||||||
* at the end of their relayout() implementation to
|
* at the end of their relayout() implementation to
|
||||||
|
@ -163,10 +163,7 @@ NodeLayout::NodeLayout(LayoutItem * parent)
|
|||||||
|
|
||||||
NodeLayout::~NodeLayout()
|
NodeLayout::~NodeLayout()
|
||||||
{
|
{
|
||||||
foreach (LayoutItem * item, d->items.keys()) {
|
releaseManagedItems();
|
||||||
item->unsetManagingLayout(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete d;
|
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
|
QSizeF NodeLayout::sizeHint() const
|
||||||
{
|
{
|
||||||
return d->sizeHint;
|
return d->sizeHint;
|
||||||
|
@ -108,6 +108,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void relayout();
|
void relayout();
|
||||||
|
void releaseManagedItems();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Private;
|
class Private;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user