From f8c74032a7180be883c32a78340e2f79afd9df71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 15 Feb 2018 21:29:18 +0100 Subject: [PATCH] GUI: Early return --- gui/resultstree.cpp | 61 +++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/gui/resultstree.cpp b/gui/resultstree.cpp index eb0c93a19..4cfbae7f1 100644 --- a/gui/resultstree.cpp +++ b/gui/resultstree.cpp @@ -921,44 +921,45 @@ void ResultsTree::recheckSelectedFiles() void ResultsTree::hideAllIdResult() { - if (mContextItem && mContextItem->parent()) { - // Make sure we are working with the first column - if (mContextItem->column() != 0) - mContextItem = mContextItem->parent()->child(mContextItem->row(), 0); - QVariantMap data = mContextItem->data().toMap(); + if (!mContextItem || !mContextItem->parent()) + return; - QString messageId = data["id"].toString(); + // Make sure we are working with the first column + if (mContextItem->column() != 0) + mContextItem = mContextItem->parent()->child(mContextItem->row(), 0); + QVariantMap data = mContextItem->data().toMap(); - // hide all errors with that message Id - int filecount = mModel.rowCount(); - for (int i = 0; i < filecount; i++) { - //Get file i - QStandardItem *file = mModel.item(i, 0); - if (!file) { + QString messageId = data["id"].toString(); + + // hide all errors with that message Id + int filecount = mModel.rowCount(); + for (int i = 0; i < filecount; i++) { + //Get file i + QStandardItem *file = mModel.item(i, 0); + if (!file) { + continue; + } + + //Get the amount of errors this file contains + int errorcount = file->rowCount(); + + for (int j = 0; j < errorcount; j++) { + //Get the error itself + QStandardItem *child = file->child(j, 0); + if (!child) { continue; } - //Get the amount of errors this file contains - int errorcount = file->rowCount(); - - for (int j = 0; j < errorcount; j++) { - //Get the error itself - QStandardItem *child = file->child(j, 0); - if (!child) { - continue; - } - - QVariantMap userdata = child->data().toMap(); - if (userdata["id"].toString() == messageId) { - userdata["hide"] = true; - child->setData(QVariant(userdata)); - } + QVariantMap userdata = child->data().toMap(); + if (userdata["id"].toString() == messageId) { + userdata["hide"] = true; + child->setData(QVariant(userdata)); } } - - refreshTree(); - emit resultsHidden(true); } + + refreshTree(); + emit resultsHidden(true); } void ResultsTree::suppressSelectedIds()