Fix reportings of static analyzer

master
Unknown 2019-03-29 04:34:17 +01:00
parent b191becd36
commit e8ebc537ea
9 changed files with 34 additions and 38 deletions

View File

@ -15,7 +15,7 @@ QVariant DrawMapFigureTableModel::headerData(int section, Qt::Orientation orient
{
return header[section];
}
else if(role == Qt::DisplayRole && orientation == Qt::Vertical){
if(role == Qt::DisplayRole && orientation == Qt::Vertical){
return section+1;
}
return QVariant();
@ -67,18 +67,18 @@ QVariant DrawMapFigureTableModel::data(const QModelIndex &index, int role) const
{
return item->getIcon();
}
else if(role == Qt::BackgroundRole)
if(role == Qt::BackgroundRole)
{
if(item->getFigure()==DrawMapFigure::Unknown){
return QBrush(Qt::red);
}
else if(col == 2 && !item->requiresPoint()){
if(col == 2 && !item->requiresPoint()){
return QBrush(Qt::lightGray);
}
else if (col == 3 && !item->requiresGeometry()){
if (col == 3 && !item->requiresGeometry()){
return QBrush(Qt::lightGray);
}
else if(col == 5 && !item->requiresText()){
if(col == 5 && !item->requiresText()){
return QBrush(Qt::lightGray);
}
}
@ -157,7 +157,7 @@ bool DrawMapFigureTableModel::setData(const QModelIndex &index, const QVariant &
emit dataChanged(index, index, QVector<int>() << role);
return true;
}
else if( index.isValid() && role == Qt::CheckStateRole &&index.column()==1){
if( index.isValid() && role == Qt::CheckStateRole &&index.column()==1){
DrawMapFigure *item = list->at(index.row());
item->setUseImageCoordinates(value.toInt() == Qt::Checked);
emit dataChanged(index, index, QVector<int>() << role);
@ -170,7 +170,7 @@ Qt::ItemFlags DrawMapFigureTableModel::flags(const QModelIndex &index) const
{
if (!index.isValid())
return Qt::NoItemFlags;
Qt::ItemFlags flag = QAbstractItemModel::flags(index);
Qt::ItemFlags flag = QAbstractTableModel::flags(index);
int col = index.column();
DrawMapFigure *item = list->at(index.row());
if(col == 0)

View File

@ -28,14 +28,14 @@ void FigureDelegate::setEditorData(QWidget *editor,
{
int value = index.model()->data(index, Qt::EditRole).toInt();
QComboBox *comboBox = static_cast<QComboBox*>(editor);
QComboBox *comboBox = dynamic_cast<QComboBox*>(editor);
comboBox->setCurrentIndex(value);
}
void FigureDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const
{
QComboBox *comboBox = static_cast<QComboBox*>(editor);
QComboBox *comboBox = dynamic_cast<QComboBox*>(editor);
model->setData(index, comboBox->currentData(), Qt::EditRole);
}

View File

@ -51,7 +51,7 @@ GeometryWidget::~GeometryWidget()
}
// Return true when parsing succeeded
// false when not (string was still accepted, mode was set to custom)
bool GeometryWidget::set(const QString geomStr, Geometry::Format requestedFormat)
bool GeometryWidget::set(const QString& geomStr, Geometry::Format requestedFormat)
{
Geometry geometry;
Geometry::Format parsedFormat;
@ -136,8 +136,8 @@ bool GeometryWidget::setFormat(Geometry::Format format)
if (format != prevFormat)
// Update all invisible widgets
return set(getGeometry(), format);
else
return true;
return true;
}
Geometry::Format GeometryWidget::getFormat() const

View File

@ -23,7 +23,7 @@ public:
explicit GeometryWidget(QWidget *parent = 0);
~GeometryWidget();
bool set(const QString geomStr, Geometry::Format format = Geometry::FormatUnknown); //{ return set(geomStr.toStdString().c_str(), format); }
bool set(const QString& geomStr, Geometry::Format format = Geometry::FormatUnknown); //{ return set(geomStr.toStdString().c_str(), format); }
bool setDefault(void) { return set(""); }
bool setFormat(int i) { return setFormat(static_cast<Geometry::Format>(i)); }
bool setFormat(Geometry::Format format);

View File

@ -9,10 +9,10 @@
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
a.setApplicationName("MinetestMapperGui");
a.setApplicationDisplayName("Minetest Mapper GUI");
a.setApplicationVersion(GIT_VERSION);
a.setOrganizationName("MinetestMapperGui");
QApplication::setApplicationName("MinetestMapperGui");
QApplication::setApplicationDisplayName("Minetest Mapper GUI");
QApplication::setApplicationVersion(GIT_VERSION);
QApplication::setOrganizationName("MinetestMapperGui");
// Setup the translators
@ -21,5 +21,5 @@ int main(int argc, char *argv[])
MainWindow w(&t);
w.show();
return a.exec();
return QApplication::exec();
}

View File

@ -535,7 +535,7 @@ void MainWindow::createProfilesMenu(){
qDebug()<<"found the Profiles"<< fileNames<< "in"<<dir.absolutePath();
if(fileNames.size()==0){
if(fileNames.empty()){
fileNames.append("default");//if nothing found create default profile
}
foreach (QString file, fileNames) {
@ -690,10 +690,10 @@ void MainWindow::readSettings()
move(settings->value("pos", QPoint(200, 200)).toPoint());
}
if(settings->value("help",false).toBool()==false){
if(!settings->value("help",false).toBool()){
ui->dockHelp->close();
}
if(settings->value("showOutputLog",false).toBool()==false){
if(!settings->value("showOutputLog",false).toBool()){
ui->dockOutput->close();
}
currentProfile = settings->value("profile","default").toString();
@ -1062,7 +1062,7 @@ void MainWindow::on_figure_geometry_apply_clicked()
void MainWindow::on_button_deleteFigure_clicked()
{
QModelIndexList indexes;
while ((indexes = ui->figures_list->selectionModel()->selectedIndexes()).size()) {
while (!(indexes = ui->figures_list->selectionModel()->selectedIndexes()).empty()) {
drawMapFigureTable->removeRow(indexes.first().row());
}
}

View File

@ -83,23 +83,19 @@ bool MakeColors::parseNodesTxt(const QString &nodesTxt)
QTextStream in(&inputFile);
while (!in.atEnd())
{
QString line = in.readLine();
if(line.isEmpty() || line.startsWith('#'))
continue;
else{
//qDebug()<< line;
QStringList lineS = line.split(' ');
const QString textureName = lineS[1];//get the filename out of the line
//Insert the texturename and a invalid Color. The color will be set by searchAndProgrssTextures
requiredColors.insert(textureName,QColor());
//Insert Nodename and texturename into QMap to be sorted in alphabetical order
nodeList.insert(lineS[0],lineS[1]);
}
//qDebug()<< line;
QStringList lineS = line.split(' ');
const QString textureName = lineS[1];//get the filename out of the line
//Insert the texturename and a invalid Color. The color will be set by searchAndProgrssTextures
requiredColors.insert(textureName,QColor());
//Insert Nodename and texturename into QMap to be sorted in alphabetical order
nodeList.insert(lineS[0],lineS[1]);
}
inputFile.close();
numberOfNodes = requiredColors.size();

View File

@ -267,7 +267,7 @@ void MinetestMapperExe::errorOccured(QProcess::ProcessError error)
qDebug() <<"Error starting MinetestMapper:"<<error
<<"Error code: "<<process->error()
<<"Error string: "<<process->errorString();
QMessageBox::critical((QWidget*)this->parent(), tr("Minetest Mapper failed"),
QMessageBox::critical(dynamic_cast<QWidget*>(this->parent()), tr("Minetest Mapper failed"),
tr("<h1>ERROR</h1> <h2>minetestmapper failed</h2>"
"Error code: <i>%1</i> <br>"
"Error Message: <pre>%2</pre><br>")

View File

@ -14,17 +14,17 @@ void Translator::load(const QLocale &locale)
{
qDebug() << "Loading Locale:" << locale;
if (qtTranslator.load(locale, "qt", "_", systemTranslationPath)) {
qApp->installTranslator(&qtTranslator);
QApplication::installTranslator(&qtTranslator);
qDebug() << "Qt Translator installed from system path" << systemTranslationPath;
}
else {
qtTranslator.load(locale, "qt", "_", translationsPath);
qApp->installTranslator(&qtTranslator);
QApplication::installTranslator(&qtTranslator);
qDebug() << "Qt Translator installed from standard path" << translationsPath;
}
if (appTranslator.load(locale, "gui", "_", translationsPath))
qApp->installTranslator(&appTranslator);
QApplication::installTranslator(&appTranslator);
}
QStringList Translator::getTranslations() const