Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 8f058752 authored by Rolf Eike Beer's avatar Rolf Eike Beer Committed by Rolf Eike Beer

check file existence before opening it, not afterwards

parent 724d8ee8
......@@ -38,7 +38,7 @@ QString KgpgInterface::getGpgSetting(const QString &name, const QString &configf
const QString tmp(name.simplified() + QLatin1Char( ' ' ));
QFile qfile(configfile);
if (qfile.open(QIODevice::ReadOnly) && (qfile.exists())) {
if (qfile.exists() && qfile.open(QIODevice::ReadOnly)) {
QTextStream t(&qfile);
while (!t.atEnd()) {
QString result(t.readLine().simplified());
......@@ -57,7 +57,7 @@ void KgpgInterface::setGpgSetting(const QString &name, const QString &value, con
{
QFile qfile(url);
if (qfile.open(QIODevice::ReadOnly) && (qfile.exists())) {
if (qfile.exists() && qfile.open(QIODevice::ReadOnly)) {
const QString temp(name + QLatin1Char( ' ' ));
QString texttowrite;
bool found = false;
......@@ -91,7 +91,7 @@ void KgpgInterface::setGpgSetting(const QString &name, const QString &value, con
bool KgpgInterface::getGpgBoolSetting(const QString &name, const QString &configfile)
{
QFile qfile(configfile);
if (qfile.open(QIODevice::ReadOnly) && (qfile.exists())) {
if (qfile.exists() && qfile.open(QIODevice::ReadOnly)) {
QTextStream t(&qfile);
while (!t.atEnd()) {
if (t.readLine().simplified().startsWith(name))
......@@ -106,7 +106,7 @@ void KgpgInterface::setGpgBoolSetting(const QString &name, const bool enable, co
{
QFile qfile(url);
if (qfile.open(QIODevice::ReadOnly) && (qfile.exists())) {
if (qfile.exists() && qfile.open(QIODevice::ReadOnly)) {
QString texttowrite;
bool found = false;
QTextStream t(&qfile);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment