GUI: Improved handling of noreturn in library editor
This commit is contained in:
parent
16851f432e
commit
4385879b72
|
@ -75,7 +75,7 @@ static CppcheckLibraryData::Function loadFunction(const QDomElement &functionEle
|
|||
function.name = functionElement.attribute("name");
|
||||
for (QDomElement childElement = functionElement.firstChildElement(); !childElement.isNull(); childElement = childElement.nextSiblingElement()) {
|
||||
if (childElement.tagName() == "noreturn")
|
||||
function.noreturn = (childElement.text() == "true");
|
||||
function.noreturn = (childElement.text() == "true") ? CppcheckLibraryData::Function::True : CppcheckLibraryData::Function::False;
|
||||
else if (childElement.tagName() == "pure")
|
||||
function.gccPure = true;
|
||||
else if (childElement.tagName() == "const")
|
||||
|
@ -160,8 +160,6 @@ bool CppcheckLibraryData::open(QIODevice &file)
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static QDomElement FunctionElement(QDomDocument &doc, const CppcheckLibraryData::Function &function)
|
||||
{
|
||||
QDomElement functionElement = doc.createElement("function");
|
||||
|
@ -172,9 +170,9 @@ static QDomElement FunctionElement(QDomDocument &doc, const CppcheckLibraryData:
|
|||
functionElement.appendChild(doc.createElement("const"));
|
||||
if (function.gccPure)
|
||||
functionElement.appendChild(doc.createElement("pure"));
|
||||
{
|
||||
if (function.noreturn != CppcheckLibraryData::Function::Unknown) {
|
||||
QDomElement e = doc.createElement("noreturn");
|
||||
e.appendChild(doc.createTextNode(function.noreturn ? "true" : "false"));
|
||||
e.appendChild(doc.createTextNode(function.noreturn == CppcheckLibraryData::Function::True ? "true" : "false"));
|
||||
functionElement.appendChild(e);
|
||||
}
|
||||
if (function.leakignore)
|
||||
|
|
|
@ -34,13 +34,13 @@ public:
|
|||
};
|
||||
|
||||
struct Function {
|
||||
Function() : noreturn(true), gccPure(false), gccConst(false),
|
||||
Function() : noreturn(Unknown), gccPure(false), gccConst(false),
|
||||
leakignore(false), useretval(false) {
|
||||
}
|
||||
|
||||
QStringList comments;
|
||||
QString name;
|
||||
bool noreturn;
|
||||
enum TrueFalseUnknown { False, True, Unknown } noreturn;
|
||||
bool gccPure;
|
||||
bool gccConst;
|
||||
bool leakignore;
|
||||
|
|
|
@ -109,7 +109,7 @@ void LibraryDialog::addFunction()
|
|||
void LibraryDialog::selectFunction(int row)
|
||||
{
|
||||
if (row == -1) {
|
||||
ui->functionreturn->setChecked(false);
|
||||
ui->noreturn->setCurrentIndex(0);
|
||||
ui->useretval->setChecked(false);
|
||||
ui->leakignore->setChecked(false);
|
||||
ui->arguments->clear();
|
||||
|
@ -118,20 +118,25 @@ void LibraryDialog::selectFunction(int row)
|
|||
|
||||
ignoreChanges = true;
|
||||
const CppcheckLibraryData::Function &function = data.functions[row];
|
||||
ui->functionreturn->setChecked(!function.noreturn);
|
||||
ui->noreturn->setCurrentIndex(function.noreturn);
|
||||
ui->useretval->setChecked(function.useretval);
|
||||
ui->leakignore->setChecked(function.leakignore);
|
||||
updateArguments(function);
|
||||
ignoreChanges = false;
|
||||
}
|
||||
|
||||
void LibraryDialog::changeFunction(int)
|
||||
{
|
||||
changeFunction();
|
||||
}
|
||||
|
||||
void LibraryDialog::changeFunction()
|
||||
{
|
||||
if (ignoreChanges)
|
||||
return;
|
||||
foreach(const QListWidgetItem *item, ui->functions->selectedItems()) {
|
||||
CppcheckLibraryData::Function &function = data.functions[ui->functions->row(item)];
|
||||
function.noreturn = !ui->functionreturn->isChecked();
|
||||
function.noreturn = (CppcheckLibraryData::Function::TrueFalseUnknown)ui->noreturn->currentIndex();
|
||||
function.useretval = ui->useretval->isChecked();
|
||||
function.leakignore = ui->leakignore->isChecked();
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ private slots:
|
|||
void addFunction();
|
||||
void selectFunction(int row);
|
||||
void changeFunction();
|
||||
void changeFunction(int);
|
||||
void editArg();
|
||||
|
||||
private:
|
||||
|
|
|
@ -95,11 +95,40 @@
|
|||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="functionreturn">
|
||||
<property name="text">
|
||||
<string>function always return</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>noreturn</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="noreturn">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>False</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>True</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Unknown</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="useretval">
|
||||
|
@ -189,22 +218,6 @@
|
|||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>functionreturn</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>LibraryDialog</receiver>
|
||||
<slot>changeFunction()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>327</x>
|
||||
<y>45</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>353</x>
|
||||
<y>2</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>useretval</sender>
|
||||
<signal>clicked()</signal>
|
||||
|
@ -285,6 +298,22 @@
|
|||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>noreturn</sender>
|
||||
<signal>currentIndexChanged(int)</signal>
|
||||
<receiver>LibraryDialog</receiver>
|
||||
<slot>changeFunction(int)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>504</x>
|
||||
<y>45</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>543</x>
|
||||
<y>32</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<slot>selectFunction(int)</slot>
|
||||
|
@ -294,5 +323,6 @@
|
|||
<slot>argumentChanged(QListWidgetItem*)</slot>
|
||||
<slot>addFunction()</slot>
|
||||
<slot>editArg()</slot>
|
||||
<slot>changeFunction(int)</slot>
|
||||
</slots>
|
||||
</ui>
|
||||
|
|
Loading…
Reference in New Issue