GUI: Use early return
This commit is contained in:
parent
526d8b76a6
commit
63feebc34f
|
@ -86,33 +86,34 @@ void LibraryDialog::openCfg()
|
||||||
filter,
|
filter,
|
||||||
&selectedFilter);
|
&selectedFilter);
|
||||||
|
|
||||||
if (!selectedFile.isEmpty()) {
|
if (selectedFile.isEmpty())
|
||||||
QFile file(selectedFile);
|
return;
|
||||||
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
|
||||||
ignoreChanges = true;
|
QFile file(selectedFile);
|
||||||
data.open(file);
|
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
mFileName = selectedFile;
|
ignoreChanges = true;
|
||||||
ui->buttonSave->setEnabled(false);
|
data.open(file);
|
||||||
ui->buttonSaveAs->setEnabled(true);
|
mFileName = selectedFile;
|
||||||
ui->filter->clear();
|
ui->buttonSave->setEnabled(false);
|
||||||
ui->functions->clear();
|
ui->buttonSaveAs->setEnabled(true);
|
||||||
for (CppcheckLibraryData::Function &function : data.functions) {
|
ui->filter->clear();
|
||||||
ui->functions->addItem(new FunctionListItem(ui->functions,
|
ui->functions->clear();
|
||||||
&function,
|
for (CppcheckLibraryData::Function &function : data.functions) {
|
||||||
false));
|
ui->functions->addItem(new FunctionListItem(ui->functions,
|
||||||
}
|
&function,
|
||||||
ui->sortFunctions->setEnabled(!data.functions.empty());
|
false));
|
||||||
ui->filter->setEnabled(!data.functions.empty());
|
|
||||||
ui->addFunction->setEnabled(true);
|
|
||||||
ignoreChanges = false;
|
|
||||||
} else {
|
|
||||||
QMessageBox msg(QMessageBox::Critical,
|
|
||||||
tr("Cppcheck"),
|
|
||||||
tr("Can not open file %1.").arg(selectedFile),
|
|
||||||
QMessageBox::Ok,
|
|
||||||
this);
|
|
||||||
msg.exec();
|
|
||||||
}
|
}
|
||||||
|
ui->sortFunctions->setEnabled(!data.functions.empty());
|
||||||
|
ui->filter->setEnabled(!data.functions.empty());
|
||||||
|
ui->addFunction->setEnabled(true);
|
||||||
|
ignoreChanges = false;
|
||||||
|
} else {
|
||||||
|
QMessageBox msg(QMessageBox::Critical,
|
||||||
|
tr("Cppcheck"),
|
||||||
|
tr("Can not open file %1.").arg(selectedFile),
|
||||||
|
QMessageBox::Ok,
|
||||||
|
this);
|
||||||
|
msg.exec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue