From 68ddd7b97824f7d510723882474e867a4a525180 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 14 Jun 2018 08:27:00 -0400 Subject: [PATCH] simplify isProfileDeletable Summary: Maintenability ++ Reviewers: #konsole, hindenburg Reviewed By: #konsole, hindenburg Subscribers: ahmadsamir, konsole-devel Tags: #konsole Differential Revision: https://phabricator.kde.org/D13516 --- src/settings/ProfileSettings.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/settings/ProfileSettings.cpp b/src/settings/ProfileSettings.cpp index 34efbe52..41868452 100644 --- a/src/settings/ProfileSettings.cpp +++ b/src/settings/ProfileSettings.cpp @@ -381,19 +381,17 @@ Profile::Ptr ProfileSettings::currentProfile() const } bool ProfileSettings::isProfileDeletable(Profile::Ptr profile) const { - if (profile) { - QFileInfo fileInfo(profile->path()); - - if (fileInfo.exists()) { - // check whether user has enough permission - QFileInfo dirInfo(fileInfo.path()); - return dirInfo.isWritable(); - } else { - return true; - } - } else { - return true; + if (!profile) { + return false; } + + const QFileInfo fileInfo(profile->path()); + if (!fileInfo.exists()) { + return false; + } + + const QFileInfo dirInfo(fileInfo.path()); + return dirInfo.isWritable(); } void ProfileSettings::updateFavoriteStatus(Profile::Ptr profile, bool favorite) {