* add API docu to the methods i added

* add a resetLayout() so layouts can release LayoutItems on deletion, avoiding dangling pointers and possible crashes

svn path=/trunk/KDE/kdebase/workspace/plasma/lib/; revision=668931
This commit is contained in:
Aaron J. Seigo 2007-05-28 05:52:05 +00:00
parent c300ff48bc
commit 3c690fea84
3 changed files with 28 additions and 0 deletions

View File

@ -70,6 +70,11 @@ qreal LayoutItem::widthForHeight(qreal h) const
return 0.0;
}
void LayoutItem::resetLayout()
{
d->layout = 0;
}
void LayoutItem::setLayout(Layout* layout)
{
if (d->layout) {

View File

@ -54,7 +54,27 @@ class KDE_EXPORT LayoutItem
virtual QSizeF sizeHint() const = 0;
/**
* Resets the layout to 0 and doesn't notify the previous layout.
* Should only be used by the current layout when relinquishing the item,
* e.g. during layout destruction.
*/
void resetLayout();
/**
* Sets the layout so that the LayoutItem may inform the layout of its
* deletion. Should only be used by the layout it is added to.
*
* If the layout item is currently associated with another layout, it will
* first remove itself from that layout.
*
* @param layout The Layout that this LayoutItem will be managed by.
*/
void setLayout(Layout* layout);
/**
* Returns the layout this item is currently associated with
*/
Layout* layout();
private:

View File

@ -44,6 +44,9 @@ VBoxLayout::VBoxLayout(LayoutItem *parent)
VBoxLayout::~VBoxLayout()
{
foreach (LayoutItem *l, d->childList) {
l->resetLayout();
}
}
Qt::Orientations VBoxLayout::expandingDirections() const