Fix up the creation of new configuration files in sysadm-general (setConfFileValue()).

This commit is contained in:
Ken Moore
2017-12-18 13:27:14 -05:00
parent dd4ab15bb4
commit c1be586f87

View File

@@ -189,12 +189,10 @@ bool General::setConfFileValue(QString fileName, QString oldKey, QString newKey,
// Load the old file, find the oldKey, remove it and replace with newKey
QFile file( oFileTmp );
if ( ! file.open( QIODevice::ReadOnly ) )
return false;
QTextStream stream( &file );
QString line;
while ( !stream.atEnd() ) {
if ( file.open( QIODevice::ReadOnly ) ){
QTextStream stream( &file );
QString line;
while ( !stream.atEnd() ) {
line = stream.readLine(); // line of text excluding '\n'
// Key is not found at all
@@ -233,10 +231,12 @@ bool General::setConfFileValue(QString fileName, QString oldKey, QString newKey,
continue;
}
}
file.close();
}else if(file.exists()){
return false; //could not read an existing file - permissions issue?
}
file.close();
// Didn't find the key? Write it!
if ( ! newKey.isEmpty() )
SavedFile << newKey;