Fix many Coverity Scan warnings

pull/2035/head
Andrei Kortunov 6 years ago
parent 194232abde
commit 4ee15ddcb9

@ -507,7 +507,7 @@ int clone(Arguments& info)
esm.endRecord(typeName.toString());
saved++;
int perc = (int)((saved / (float)recordCount)*100);
int perc = recordCount == 0 ? 100 : (int)((saved / (float)recordCount)*100);
if (perc % 10 == 0)
{
std::cerr << "\r" << perc << "%";

@ -860,11 +860,12 @@ std::vector<std::string>::iterator MwIniImporter::findString(std::vector<std::st
}
void MwIniImporter::addPaths(std::vector<boost::filesystem::path>& output, std::vector<std::string> input) {
for (auto& path : input) {
for (auto& path : input)
{
if (path.front() == '"')
{
path.erase(path.begin());
path.erase(path.end() - 1);
// Drop first and last characters - quotation marks
path = path.substr(1, path.size() - 2);
}
output.emplace_back(path);
}

@ -9,7 +9,7 @@
#include "document.hpp"
CSMDoc::DocumentManager::DocumentManager (const Files::ConfigurationManager& configuration)
: mConfiguration (configuration), mEncoding (ToUTF8::WINDOWS_1252)
: mConfiguration (configuration), mEncoding (ToUTF8::WINDOWS_1252), mFsStrict(false)
{
boost::filesystem::path projectPath = configuration.getUserDataPath() / "projects";

@ -5,6 +5,8 @@
#include <QAction>
#include <QWidget>
#include <components/debug/debuglog.hpp>
#include "state.hpp"
#include "shortcutmanager.hpp"
@ -71,7 +73,14 @@ namespace CSMPrefs
Shortcut::~Shortcut()
{
State::get().getShortcutManager().removeShortcut(this);
try
{
State::get().getShortcutManager().removeShortcut(this);
}
catch(const std::exception& e)
{
Log(Debug::Error) << "Error in the destructor: " << e.what();
}
}
bool Shortcut::isEnabled() const

@ -21,6 +21,11 @@ namespace CSMWorld
return mIsBeast;
}
ActorAdapter::RaceData::RaceData()
{
mIsBeast = false;
}
bool ActorAdapter::RaceData::handlesPart(ESM::PartReferenceType type) const
{
switch (type)
@ -83,6 +88,12 @@ namespace CSMWorld
}
ActorAdapter::ActorData::ActorData()
{
mCreature = false;
mFemale = false;
}
const std::string& ActorAdapter::ActorData::getId() const
{
return mId;

@ -43,6 +43,8 @@ namespace CSMWorld
class RaceData
{
public:
RaceData();
/// Retrieves the id of the race represented
const std::string& getId() const;
/// Checks if it's a beast race
@ -80,6 +82,8 @@ namespace CSMWorld
class ActorData
{
public:
ActorData();
/// Retrieves the id of the actor represented
const std::string& getId() const;
/// Checks if the actor is a creature

@ -198,7 +198,11 @@ CSMWorld::ModifyCommand::ModifyCommand (QAbstractItemModel& model, const QModelI
if (mIndex.parent().isValid())
{
setText ("Modify " + dynamic_cast<CSMWorld::IdTree*>(mModel)->nestedHeaderData (
CSMWorld::IdTree* tree = dynamic_cast<CSMWorld::IdTree*>(mModel);
assert(tree != nullptr);
setText ("Modify " + tree->nestedHeaderData (
mIndex.parent().column(), mIndex.column(), Qt::Horizontal, Qt::DisplayRole).toString());
}
else

@ -8,6 +8,8 @@
#include <QStackedWidget>
#include <QListWidgetItem>
#include <components/debug/debuglog.hpp>
#include "../../model/prefs/state.hpp"
#include "page.hpp"
@ -77,8 +79,15 @@ CSVPrefs::Dialogue::Dialogue()
CSVPrefs::Dialogue::~Dialogue()
{
if (isVisible())
CSMPrefs::State::get().save();
try
{
if (isVisible())
CSMPrefs::State::get().save();
}
catch(const std::exception& e)
{
Log(Debug::Error) << "Error in the destructor: " << e.what();
}
}
void CSVPrefs::Dialogue::closeEvent (QCloseEvent *event)

@ -463,6 +463,7 @@ namespace CSVRender
, mDistance(0)
, mOrbitSpeed(osg::PI / 4)
, mOrbitSpeedMult(4)
, mConstRoll(false)
{
CSMPrefs::Shortcut* naviPrimaryShortcut = new CSMPrefs::Shortcut("scene-navi-primary", widget);
naviPrimaryShortcut->enable(false);

@ -227,6 +227,8 @@ namespace CSVRender
CSMWorld::IdTree* model = dynamic_cast<CSMWorld::IdTree*>(mData.getTableModel(
CSMWorld::UniversalId::Type_Pathgrids));
assert(model != nullptr);
const CSMWorld::Pathgrid* source = getPathgridSource();
if (source)
{
@ -360,6 +362,8 @@ namespace CSVRender
CSMWorld::IdTree* model = dynamic_cast<CSMWorld::IdTree*>(mData.getTableModel(
CSMWorld::UniversalId::Type_Pathgrids));
assert(model != nullptr);
// Want to remove nodes from end of list first
std::sort(mSelected.begin(), mSelected.end(), std::greater<int>());
@ -461,6 +465,8 @@ namespace CSVRender
CSMWorld::IdTree* model = dynamic_cast<CSMWorld::IdTree*>(mData.getTableModel(
CSMWorld::UniversalId::Type_Pathgrids));
assert(model != nullptr);
int parentColumn = mPathgridCollection.findColumnIndex(CSMWorld::Columns::ColumnId_PathgridEdges);
std::set<int, std::greater<int> >::iterator row;
@ -636,6 +642,8 @@ namespace CSVRender
CSMWorld::IdTree* model = dynamic_cast<CSMWorld::IdTree*>(mData.getTableModel(
CSMWorld::UniversalId::Type_Pathgrids));
assert(model != nullptr);
int recordIndex = mPathgridCollection.getIndex(mId);
int parentColumn = mPathgridCollection.findColumnIndex(CSMWorld::Columns::ColumnId_PathgridEdges);

@ -13,6 +13,7 @@
#include <osg/Material>
#include <osg/Version>
#include <components/debug/debuglog.hpp>
#include <components/resource/scenemanager.hpp>
#include <components/resource/resourcesystem.hpp>
#include <components/sceneutil/lightmanager.hpp>
@ -96,7 +97,14 @@ RenderWidget::RenderWidget(QWidget *parent, Qt::WindowFlags f)
RenderWidget::~RenderWidget()
{
CompositeViewer::get().removeView(mView);
try
{
CompositeViewer::get().removeView(mView);
}
catch(const std::exception& e)
{
Log(Debug::Error) << "Error in the destructor: " << e.what();
}
}
void RenderWidget::flagAsModified()

@ -256,9 +256,9 @@ void CSVRender::TerrainTextureMode::editTerrainTextureGrid(const WorldspaceHitRe
std::string mBrushTextureInt = mBrushTexture.substr (hashlocation+1);
int brushInt = stoi(mBrushTexture.substr (hashlocation+1))+1; // All indices are offset by +1
float rf = mBrushSize/2;
int r = (mBrushSize/2)+1;
float distance = 0;
int rf = mBrushSize / 2;
int r = mBrushSize / 2 + 1;
int distance = 0;
if (mBrushShape == 0)
{

@ -25,7 +25,7 @@ std::string CSVWorld::CellCreator::getId() const
void CSVWorld::CellCreator::configureCreateCommand(CSMWorld::CreateCommand& command) const
{
CSMWorld::IdTree *model = dynamic_cast<CSMWorld::IdTree *>(getData().getTableModel(getCollectionId()));
Q_ASSERT(model != nullptr);
assert(model != nullptr);
int parentIndex = model->findColumnIndex(CSMWorld::Columns::ColumnId_Cell);
int index = model->findNestedColumnIndex(parentIndex, CSMWorld::Columns::ColumnId_Interior);
command.addNestedValue(parentIndex, index, mType->currentIndex() == 0);

@ -555,8 +555,10 @@ void CSVWorld::EditWidget::remake(int row)
if (mTable->hasChildren(mTable->index(row, i)) &&
!(flags & CSMWorld::ColumnBase::Flag_Dialogue_List))
{
mNestedModels.push_back(new CSMWorld::NestedTableProxyModel (
mTable->index(row, i), display, dynamic_cast<CSMWorld::IdTree*>(mTable)));
CSMWorld::IdTree *innerTable = dynamic_cast<CSMWorld::IdTree*>(mTable);
assert(innerTable != nullptr);
mNestedModels.push_back(new CSMWorld::NestedTableProxyModel (mTable->index(row, i), display, innerTable));
int idColumn = mTable->findColumnIndex (CSMWorld::Columns::ColumnId_Id);
int typeColumn = mTable->findColumnIndex (CSMWorld::Columns::ColumnId_RecordType);

@ -81,8 +81,11 @@ void CSVWorld::ScriptHighlighter::highlight (const Compiler::TokenLoc& loc, Type
CSVWorld::ScriptHighlighter::ScriptHighlighter (const CSMWorld::Data& data, Mode mode,
QTextDocument *parent)
: QSyntaxHighlighter (parent), Compiler::Parser (mErrorHandler, mContext), mContext (data),
mMode (mode)
: QSyntaxHighlighter (parent)
, Compiler::Parser (mErrorHandler, mContext)
, mContext (data)
, mMode (mode)
, mMarkOccurrences (false)
{
QColor color ("black");
QTextCharFormat format;

@ -955,6 +955,7 @@ namespace MWMechanics
, mStoredInitialActorPosition(wander->mStoredInitialActorPosition)
, mHasDestination(false)
, mDestination(osg::Vec3f(0, 0, 0))
, mUsePathgrid(false)
{
if (mStoredInitialActorPosition)
mInitialActorPosition = wander->mInitialActorPosition;

@ -431,6 +431,7 @@ size_t FFmpeg_Decoder::getSampleOffset()
FFmpeg_Decoder::FFmpeg_Decoder(const VFS::Manager* vfs)
: Sound_Decoder(vfs)
, mFormatCtx(nullptr)
, mCodecCtx(nullptr)
, mStream(nullptr)
, mFrame(nullptr)
, mFrameSize(0)

@ -129,6 +129,7 @@ namespace
config.bmin[2] -= getBorderSize(settings);
config.bmax[0] += getBorderSize(settings);
config.bmax[2] += getBorderSize(settings);
config.tileSize = settings.mTileSize;
return config;
}

Loading…
Cancel
Save