From: Sebastian Trueg Date: Thu, 28 Jan 2010 14:09:22 +0000 (+0000) Subject: Another fix for the metadata rows: properly clean up unused rows in case no metadata... X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/5e079195bc38768041365b64f1a70285261125fd Another fix for the metadata rows: properly clean up unused rows in case no metadata is added. svn path=/trunk/KDE/kdebase/apps/; revision=1081502 --- diff --git a/src/panels/information/kmetadatawidget.cpp b/src/panels/information/kmetadatawidget.cpp index a17a0fd8f..c8d7838c9 100644 --- a/src/panels/information/kmetadatawidget.cpp +++ b/src/panels/information/kmetadatawidget.cpp @@ -368,9 +368,9 @@ void KMetaDataWidget::Private::slotLoadingFinished() // Show the remaining meta information as text. The number // of required rows may very. Existing rows are reused to // prevent flickering. - int index = 8; // TODO: don't hardcode this value here + int usedRowCnt = 8; // TODO: don't hardcode this value here const int rowCount = m_rows.count(); - Q_ASSERT(rowCount >= index); + Q_ASSERT(rowCount >= usedRowCnt); const QList items = mergedItems(m_loadMetaDataThread->items()); foreach (const KLoadMetaDataThread::Item& item, items) { @@ -389,10 +389,10 @@ void KMetaDataWidget::Private::slotLoadingFinished() .arg(decoration); itemValue.insert(3 /* after "setText(itemLabel); - QLabel* infoValueLabel = qobject_cast(m_rows[index].infoWidget); + m_rows[usedRowCnt].label->setText(itemLabel); + QLabel* infoValueLabel = qobject_cast(m_rows[usedRowCnt].infoWidget); Q_ASSERT(infoValueLabel != 0); infoValueLabel->setText(itemValue); } else { @@ -403,14 +403,11 @@ void KMetaDataWidget::Private::slotLoadingFinished() q, SLOT(slotLinkActivated(QString))); addRow(infoLabel, infoValue); } - ++index; - } - if (items.count() > 0) { - --index; + ++usedRowCnt; } // remove rows that are not needed anymore - for (int i = m_rows.count() - 1; i > index; --i) { + for (int i = m_rows.count() - 1; i >= usedRowCnt; --i) { delete m_rows[i].label; delete m_rows[i].infoWidget; m_rows.pop_back();