From f07525183c2a9fd947dffd3c4503546b24d4519a Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Wed, 6 Mar 2013 18:24:19 +0100 Subject: [PATCH] Simplify function with early return. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: Ic0e1a32f6c586e75fb7389ef8009e56881942cf1 Reviewed-by: Laszlo Papp Reviewed-by: Jędrzej Nowacki --- src/quick/items/qquickloader.cpp | 65 +++++++++++++++++++------------------ 1 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/quick/items/qquickloader.cpp b/src/quick/items/qquickloader.cpp index 61f9a27..0434c2a 100644 --- a/src/quick/items/qquickloader.cpp +++ b/src/quick/items/qquickloader.cpp @@ -335,41 +335,42 @@ bool QQuickLoader::active() const void QQuickLoader::setActive(bool newVal) { Q_D(QQuickLoader); - if (d->active != newVal) { - d->active = newVal; - if (newVal == true) { - if (d->loadingFromSource) { - loadFromSource(); - } else { - loadFromSourceComponent(); - } + if (d->active == newVal) + return; + + d->active = newVal; + if (newVal == true) { + if (d->loadingFromSource) { + loadFromSource(); } else { - // cancel any current incubation - if (d->incubator) { - d->incubator->clear(); - delete d->itemContext; - d->itemContext = 0; - } + loadFromSourceComponent(); + } + } else { + // cancel any current incubation + if (d->incubator) { + d->incubator->clear(); + delete d->itemContext; + d->itemContext = 0; + } - if (d->item) { - QQuickItemPrivate *p = QQuickItemPrivate::get(d->item); - p->removeItemChangeListener(d, watchedChanges); + if (d->item) { + QQuickItemPrivate *p = QQuickItemPrivate::get(d->item); + p->removeItemChangeListener(d, watchedChanges); - // We can't delete immediately because our item may have triggered - // the Loader to load a different item. - d->item->setParentItem(0); - d->item->setVisible(false); - d->item = 0; - } - if (d->object) { - d->object->deleteLater(); - d->object = 0; - emit itemChanged(); - } - emit statusChanged(); + // We can't delete immediately because our item may have triggered + // the Loader to load a different item. + d->item->setParentItem(0); + d->item->setVisible(false); + d->item = 0; + } + if (d->object) { + d->object->deleteLater(); + d->object = 0; + emit itemChanged(); } - emit activeChanged(); + emit statusChanged(); } + emit activeChanged(); } -- 1.7.2.5