GUI: Only edit contract for non-bailout warnings

This commit is contained in:
Daniel Marjamäki 2020-04-27 19:43:38 +02:00
parent dae009ca01
commit c19a9c2ad9
2 changed files with 9 additions and 4 deletions

View File

@ -52,6 +52,11 @@
static const unsigned int COLUMN_SINCE_DATE = 6; static const unsigned int COLUMN_SINCE_DATE = 6;
static const unsigned int COLUMN_TAGS = 7; static const unsigned int COLUMN_TAGS = 7;
static QString getFunction(QStandardItem *item)
{
return item->data().toMap().value("function").toString();
}
ResultsTree::ResultsTree(QWidget * parent) : ResultsTree::ResultsTree(QWidget * parent) :
QTreeView(parent), QTreeView(parent),
mSettings(nullptr), mSettings(nullptr),
@ -613,7 +618,7 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
const bool bughunting = !multipleSelection && mContextItem->data().toMap().value("id").toString().startsWith("bughunting"); const bool bughunting = !multipleSelection && mContextItem->data().toMap().value("id").toString().startsWith("bughunting");
if (bughunting) { if (bughunting && !getFunction(mContextItem).isEmpty()) {
QAction *editContract = new QAction(tr("Edit contract.."), &menu); QAction *editContract = new QAction(tr("Edit contract.."), &menu);
connect(editContract, &QAction::triggered, this, &ResultsTree::editContract); connect(editContract, &QAction::triggered, this, &ResultsTree::editContract);
menu.addAction(editContract); menu.addAction(editContract);
@ -1035,8 +1040,7 @@ void ResultsTree::openContainingFolder()
void ResultsTree::editContract() void ResultsTree::editContract()
{ {
QString function = mContextItem->data().toMap().value("function").toString(); emit editFunctionContract(getFunction(mContextItem));
emit editFunctionContract(function);
} }
void ResultsTree::tagSelectedItems(const QString &tag) void ResultsTree::tagSelectedItems(const QString &tag)

View File

@ -1855,7 +1855,8 @@ void ExprEngine::runChecks(ErrorLogger *errorLogger, const Tokenizer *tokenizer,
std::list<const Token*> callstack{settings->clang ? tok : tok->astParent()}; std::list<const Token*> callstack{settings->clang ? tok : tok->astParent()};
const char * const id = (tok->valueType() && tok->valueType()->isFloat()) ? "bughuntingDivByZeroFloat" : "bughuntingDivByZero"; const char * const id = (tok->valueType() && tok->valueType()->isFloat()) ? "bughuntingDivByZeroFloat" : "bughuntingDivByZero";
ErrorLogger::ErrorMessage errmsg(callstack, &tokenizer->list, Severity::SeverityType::error, id, "There is division, cannot determine that there can't be a division by zero.", CWE(369), false); ErrorLogger::ErrorMessage errmsg(callstack, &tokenizer->list, Severity::SeverityType::error, id, "There is division, cannot determine that there can't be a division by zero.", CWE(369), false);
errmsg.function = dataBase->currentFunction; if (value.type != ExprEngine::ValueType::BailoutValue)
errmsg.function = dataBase->currentFunction;
errorLogger->reportErr(errmsg); errorLogger->reportErr(errmsg);
} }
}; };