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

View File

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

View File

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

View File

@ -23,7 +23,7 @@ public:
explicit GeometryWidget(QWidget *parent = 0); explicit GeometryWidget(QWidget *parent = 0);
~GeometryWidget(); ~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 setDefault(void) { return set(""); }
bool setFormat(int i) { return setFormat(static_cast<Geometry::Format>(i)); } bool setFormat(int i) { return setFormat(static_cast<Geometry::Format>(i)); }
bool setFormat(Geometry::Format format); bool setFormat(Geometry::Format format);

View File

@ -9,10 +9,10 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QApplication a(argc, argv); QApplication a(argc, argv);
a.setApplicationName("MinetestMapperGui"); QApplication::setApplicationName("MinetestMapperGui");
a.setApplicationDisplayName("Minetest Mapper GUI"); QApplication::setApplicationDisplayName("Minetest Mapper GUI");
a.setApplicationVersion(GIT_VERSION); QApplication::setApplicationVersion(GIT_VERSION);
a.setOrganizationName("MinetestMapperGui"); QApplication::setOrganizationName("MinetestMapperGui");
// Setup the translators // Setup the translators
@ -21,5 +21,5 @@ int main(int argc, char *argv[])
MainWindow w(&t); MainWindow w(&t);
w.show(); 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(); qDebug()<<"found the Profiles"<< fileNames<< "in"<<dir.absolutePath();
if(fileNames.size()==0){ if(fileNames.empty()){
fileNames.append("default");//if nothing found create default profile fileNames.append("default");//if nothing found create default profile
} }
foreach (QString file, fileNames) { foreach (QString file, fileNames) {
@ -690,10 +690,10 @@ void MainWindow::readSettings()
move(settings->value("pos", QPoint(200, 200)).toPoint()); move(settings->value("pos", QPoint(200, 200)).toPoint());
} }
if(settings->value("help",false).toBool()==false){ if(!settings->value("help",false).toBool()){
ui->dockHelp->close(); ui->dockHelp->close();
} }
if(settings->value("showOutputLog",false).toBool()==false){ if(!settings->value("showOutputLog",false).toBool()){
ui->dockOutput->close(); ui->dockOutput->close();
} }
currentProfile = settings->value("profile","default").toString(); currentProfile = settings->value("profile","default").toString();
@ -1062,7 +1062,7 @@ void MainWindow::on_figure_geometry_apply_clicked()
void MainWindow::on_button_deleteFigure_clicked() void MainWindow::on_button_deleteFigure_clicked()
{ {
QModelIndexList indexes; QModelIndexList indexes;
while ((indexes = ui->figures_list->selectionModel()->selectedIndexes()).size()) { while (!(indexes = ui->figures_list->selectionModel()->selectedIndexes()).empty()) {
drawMapFigureTable->removeRow(indexes.first().row()); drawMapFigureTable->removeRow(indexes.first().row());
} }
} }

View File

@ -83,23 +83,19 @@ bool MakeColors::parseNodesTxt(const QString &nodesTxt)
QTextStream in(&inputFile); QTextStream in(&inputFile);
while (!in.atEnd()) while (!in.atEnd())
{ {
QString line = in.readLine(); QString line = in.readLine();
if(line.isEmpty() || line.startsWith('#')) if(line.isEmpty() || line.startsWith('#'))
continue; continue;
else{
//qDebug()<< line; //qDebug()<< line;
QStringList lineS = line.split(' '); QStringList lineS = line.split(' ');
const QString textureName = lineS[1];//get the filename out of the line 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]);
}
//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(); inputFile.close();
numberOfNodes = requiredColors.size(); numberOfNodes = requiredColors.size();

View File

@ -267,7 +267,7 @@ void MinetestMapperExe::errorOccured(QProcess::ProcessError error)
qDebug() <<"Error starting MinetestMapper:"<<error qDebug() <<"Error starting MinetestMapper:"<<error
<<"Error code: "<<process->error() <<"Error code: "<<process->error()
<<"Error string: "<<process->errorString(); <<"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>" tr("<h1>ERROR</h1> <h2>minetestmapper failed</h2>"
"Error code: <i>%1</i> <br>" "Error code: <i>%1</i> <br>"
"Error Message: <pre>%2</pre><br>") "Error Message: <pre>%2</pre><br>")

View File

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