From 9c3f5040bc9b80619ebe167c352ac8f0394f9b41 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Fri, 15 May 2009 11:43:09 +0200 Subject: Cleaning bug in custom layout example. The example was using deleteAllItems() to delete items from the layout. This method is now part of the QT3_SUPPORT and shold not be used if not needed. Replaced by deleting all items one by one. Task-number: 220656 Rev-by: janarve --- doc/src/layout.qdoc | 6 +++--- doc/src/snippets/code/doc_src_layout.qdoc | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/doc/src/layout.qdoc b/doc/src/layout.qdoc index 196999be1c..d97fcfc1d2 100644 --- a/doc/src/layout.qdoc +++ b/doc/src/layout.qdoc @@ -343,9 +343,9 @@ \snippet doc/src/snippets/code/doc_src_layout.qdoc 4 The layout takes over responsibility of the items added. Since QLayoutItem - does not inherit QObject, we must delete the items manually. The function - QLayout::deleteAllItems() uses \c{takeAt()} defined above to delete all the - items in the layout. + does not inherit QObject, we must delete the items manually. In the + destructor, we remove each item from the list using \c{takeAt()}, and + then delete it. \snippet doc/src/snippets/code/doc_src_layout.qdoc 5 diff --git a/doc/src/snippets/code/doc_src_layout.qdoc b/doc/src/snippets/code/doc_src_layout.qdoc index fedcf0c04c..60f36b0b9a 100644 --- a/doc/src/snippets/code/doc_src_layout.qdoc +++ b/doc/src/snippets/code/doc_src_layout.qdoc @@ -67,7 +67,9 @@ void CardLayout::addItem(QLayoutItem *item) //! [5] CardLayout::~CardLayout() { - deleteAllItems(); + QLayoutItem *item; + while ((item = takeAt(0))) + delete item; } //! [5] @@ -121,4 +123,4 @@ QSize CardLayout::minimumSize() const } return s + n*QSize(spacing(), spacing()); } -//! [7] \ No newline at end of file +//! [7] -- cgit v1.2.1