Merge pull request #3040 from akortunov/pvs

Fix some issues, found by PVS Studio
cherry-pick-c431f31c
Bret Curtis 4 years ago committed by GitHub
commit a735bbe9a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -108,7 +108,7 @@ bool Launcher::AdvancedPage::loadSettings()
loadSettingBool(magicItemAnimationsCheckBox, "use magic item animations", "Game");
connect(animSourcesCheckBox, SIGNAL(toggled(bool)), this, SLOT(slotAnimSourcesToggled(bool)));
loadSettingBool(animSourcesCheckBox, "use additional anim sources", "Game");
if (animSourcesCheckBox->checkState())
if (animSourcesCheckBox->checkState() != Qt::Unchecked)
{
loadSettingBool(weaponSheathingCheckBox, "weapon sheathing", "Game");
loadSettingBool(shieldSheathingCheckBox, "shield sheathing", "Game");

@ -206,7 +206,7 @@ void Launcher::GraphicsPage::saveSettings()
if (cScreen != mEngineSettings.getInt("screen", "Video"))
mEngineSettings.setInt("screen", "Video", cScreen);
if (framerateLimitCheckBox->checkState())
if (framerateLimitCheckBox->checkState() != Qt::Unchecked)
{
float cFpsLimit = framerateLimitSpinBox->value();
if (cFpsLimit != mEngineSettings.getFloat("framerate limit", "Video"))
@ -217,7 +217,7 @@ void Launcher::GraphicsPage::saveSettings()
mEngineSettings.setFloat("framerate limit", "Video", 0);
}
int cShadowDist = shadowDistanceCheckBox->checkState() ? shadowDistanceSpinBox->value() : 0;
int cShadowDist = shadowDistanceCheckBox->checkState() != Qt::Unchecked ? shadowDistanceSpinBox->value() : 0;
if (mEngineSettings.getInt("maximum shadow map distance", "Shadows") != cShadowDist)
mEngineSettings.setInt("maximum shadow map distance", "Shadows", cShadowDist);
float cFadeStart = fadeStartSpinBox->value();

@ -325,12 +325,6 @@ std::shared_ptr<CSMFilter::Node> CSMFilter::Parser::parseNAry (const Token& keyw
break;
}
if (nodes.empty())
{
error();
return std::shared_ptr<Node>();
}
switch (keyword.mType)
{
case Token::Type_Keyword_And: return std::shared_ptr<CSMFilter::Node> (new AndNode (nodes));

@ -10,7 +10,7 @@
#include "nestedtablewrapper.hpp"
CSMWorld::PotionColumns::PotionColumns (const InventoryColumns& columns)
: InventoryColumns (columns) {}
: InventoryColumns (columns), mEffects(nullptr) {}
CSMWorld::PotionRefIdAdapter::PotionRefIdAdapter (const PotionColumns& columns,
const RefIdColumn *autoCalc)

@ -115,7 +115,7 @@ namespace CSMWorld
{
const RefIdColumn *mModel;
ModelColumns (const BaseColumns& base) : BaseColumns (base) {}
ModelColumns (const BaseColumns& base) : BaseColumns (base), mModel(nullptr) {}
};
/// \brief Adapter for IDs with models (all but levelled lists)
@ -1858,18 +1858,18 @@ namespace CSMWorld
break; // always save
case 16:
if (content.mType == ESM::AI_Travel)
content.mTravel.mZ = value.toFloat();
content.mTravel.mX = value.toFloat();
else if (content.mType == ESM::AI_Follow || content.mType == ESM::AI_Escort)
content.mTarget.mZ = value.toFloat();
content.mTarget.mX = value.toFloat();
else
return; // return without saving
break; // always save
case 17:
if (content.mType == ESM::AI_Travel)
content.mTravel.mZ = value.toFloat();
content.mTravel.mY = value.toFloat();
else if (content.mType == ESM::AI_Follow || content.mType == ESM::AI_Escort)
content.mTarget.mZ = value.toFloat();
content.mTarget.mY = value.toFloat();
else
return; // return without saving

@ -438,8 +438,8 @@ void CSVDoc::View::updateActions()
for (std::vector<QAction *>::iterator iter (mEditingActions.begin()); iter!=mEditingActions.end(); ++iter)
(*iter)->setEnabled (editing);
mUndo->setEnabled (editing & mDocument->getUndoStack().canUndo());
mRedo->setEnabled (editing & mDocument->getUndoStack().canRedo());
mUndo->setEnabled (editing && mDocument->getUndoStack().canUndo());
mRedo->setEnabled (editing && mDocument->getUndoStack().canRedo());
mSave->setEnabled (!(mDocument->getState() & CSMDoc::State_Saving) && !running);
mVerify->setEnabled (!(mDocument->getState() & CSMDoc::State_Verifying));

@ -427,14 +427,8 @@ void CSVRender::TerrainTextureMode::editTerrainTextureGrid(const WorldspaceHitRe
{
if (i_cell == cellX && j_cell == cellY && abs(i-xHitInCell) < r && abs(j-yHitInCell) < r)
{
int distanceX(0);
int distanceY(0);
if (i_cell < cellX) distanceX = xHitInCell + landTextureSize * abs(i_cell-cellX) - i;
if (j_cell < cellY) distanceY = yHitInCell + landTextureSize * abs(j_cell-cellY) - j;
if (i_cell > cellX) distanceX = -xHitInCell + landTextureSize* abs(i_cell-cellX) + i;
if (j_cell > cellY) distanceY = -yHitInCell + landTextureSize * abs(j_cell-cellY) + j;
if (i_cell == cellX) distanceX = abs(i-xHitInCell);
if (j_cell == cellY) distanceY = abs(j-yHitInCell);
int distanceX = abs(i-xHitInCell);
int distanceY = abs(j-yHitInCell);
float distance = std::round(sqrt(pow(distanceX, 2)+pow(distanceY, 2)));
float rf = static_cast<float>(mBrushSize) / 2;
if (distance < rf) newTerrain[j*landTextureSize+i] = brushInt;

@ -20,7 +20,8 @@ CSMWorld::UniversalId CSVWorld::DragDropUtils::getAcceptedData(const QDropEvent
{
if (canAcceptData(event, type))
{
return getTableMimeData(event)->returnMatching(type);
if (const CSMWorld::TableMimeData *data = getTableMimeData(event))
return data->returnMatching(type);
}
return CSMWorld::UniversalId::Type_None;
}

@ -19,14 +19,10 @@ void CSVWorld::DragRecordTable::startDragFromTable (const CSVWorld::DragRecordTa
}
CSMWorld::TableMimeData* mime = new CSMWorld::TableMimeData (records, mDocument);
if (mime)
{
QDrag* drag = new QDrag (this);
drag->setMimeData (mime);
drag->setPixmap (QString::fromUtf8 (mime->getIcon().c_str()));
drag->exec (Qt::CopyAction);
}
QDrag* drag = new QDrag (this);
drag->setMimeData (mime);
drag->setPixmap (QString::fromUtf8 (mime->getIcon().c_str()));
drag->exec (Qt::CopyAction);
}
CSVWorld::DragRecordTable::DragRecordTable (CSMDoc::Document& document, QWidget* parent) :

@ -261,16 +261,10 @@ QWidget *CSVWorld::CommandDelegate::createEditor (QWidget *parent, const QStyleO
return dsb;
}
/// \todo implement size limit. QPlainTextEdit does not support a size limit.
case CSMWorld::ColumnBase::Display_LongString:
{
QPlainTextEdit *edit = new QPlainTextEdit(parent);
edit->setUndoRedoEnabled (false);
return edit;
}
case CSMWorld::ColumnBase::Display_LongString256:
{
/// \todo implement size limit. QPlainTextEdit does not support a size limit.
QPlainTextEdit *edit = new QPlainTextEdit(parent);
edit->setUndoRedoEnabled (false);
return edit;

@ -587,7 +587,7 @@ namespace MWGui
// effect box can have variable width -> variable left coordinate
int effectsDx = 0;
if (!mMinimapBox->getVisible ())
effectsDx = (viewSize.width - mMinimapBoxBaseRight) - (viewSize.width - mEffectBoxBaseRight);
effectsDx = mEffectBoxBaseRight - mMinimapBoxBaseRight;
mMapVisible = mMinimapBox->getVisible ();
if (!mMapVisible)

@ -561,7 +561,7 @@ namespace
if (mAllQuests)
{
SetNamesInactive setInactive(list);
mModel->visitQuestNames(!mAllQuests, setInactive);
mModel->visitQuestNames(false, setInactive);
}
MWBase::Environment::get().getWindowManager()->playSound("book page");

@ -28,10 +28,7 @@ namespace MWGui
MessageBoxManager::~MessageBoxManager ()
{
for (MessageBox* messageBox : mMessageBoxes)
{
delete messageBox;
}
MessageBoxManager::clear();
}
int MessageBoxManager::getMessagesCount()

@ -99,7 +99,6 @@ namespace MWMechanics
{
AiPackage::Options options;
options.mUseVariableSpeed = true;
options.mRepeat = false;
return options;
}

@ -446,9 +446,9 @@ std::string CharacterController::fallbackShortWeaponGroup(const std::string& bas
const ESM::WeaponType* weapInfo = getWeaponType(mWeaponType);
// For real two-handed melee weapons use 2h swords animations as fallback, otherwise use the 1h ones
if (isRealWeapon && weapInfo->mFlags & ESM::WeaponType::TwoHanded && weapInfo->mWeaponClass == ESM::WeaponType::Melee)
if (weapInfo->mFlags & ESM::WeaponType::TwoHanded && weapInfo->mWeaponClass == ESM::WeaponType::Melee)
groupName += twoHandFallback;
else if (isRealWeapon)
else
groupName += oneHandFallback;
// Special case for crossbows - we shouls apply 1h animations a fallback only for lower body

@ -4,8 +4,6 @@
namespace MWMechanics
{
static const ESM::WeaponType *sWeaponTypeListEnd = &sWeaponTypeList[sizeof(sWeaponTypeList)/sizeof(sWeaponTypeList[0])];
MWWorld::ContainerStoreIterator getActiveWeapon(MWWorld::Ptr actor, int *weaptype)
{
MWWorld::InventoryStore &inv = actor.getClass().getInventoryStore(actor);

@ -152,6 +152,9 @@ namespace MWPhysics
, mNextLOS(0)
, mFrameNumber(0)
, mTimer(osg::Timer::instance())
, mTimeBegin(0)
, mTimeEnd(0)
, mFrameStart(0)
{
mNumThreads = Config::computeNumThreads(mThreadSafeBullet);

@ -583,7 +583,7 @@ namespace MWRender
}
mOverlayImage->copySubImage(imageDest.mX, imageDest.mY, 0, imageDest.mImage);
it = mPendingImageDest.erase(it);
mPendingImageDest.erase(it);
return true;
}
}

@ -135,7 +135,7 @@ public:
mClipNodeTransform = new osg::Group;
mClipNodeTransform->addCullCallback(new FlipCallback(&mPlane));
addChild(mClipNodeTransform);
osg::Group::addChild(mClipNodeTransform);
mClipNode = new osg::ClipNode;
@ -240,7 +240,7 @@ public:
setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
setReferenceFrame(osg::Camera::RELATIVE_RF);
setSmallFeatureCullingPixelSize(Settings::Manager::getInt("small feature culling pixel size", "Water"));
setName("RefractionCamera");
osg::Camera::setName("RefractionCamera");
setCullCallback(new InheritViewPointCallback);
setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
@ -261,7 +261,7 @@ public:
getOrCreateStateSet()->setAttributeAndModes(fog, osg::StateAttribute::OFF|osg::StateAttribute::OVERRIDE);
mClipCullNode = new ClipCullNode;
addChild(mClipCullNode);
osg::Camera::addChild(mClipCullNode);
mRefractionTexture = new osg::Texture2D;
mRefractionTexture->setTextureSize(rttSize, rttSize);
@ -335,7 +335,7 @@ public:
setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
setReferenceFrame(osg::Camera::RELATIVE_RF);
setSmallFeatureCullingPixelSize(Settings::Manager::getInt("small feature culling pixel size", "Water"));
setName("ReflectionCamera");
osg::Camera::setName("ReflectionCamera");
setCullCallback(new InheritViewPointCallback);
setInterior(isInterior);
@ -364,7 +364,7 @@ public:
getOrCreateStateSet()->setAttributeAndModes(frontFace, osg::StateAttribute::ON);
mClipCullNode = new ClipCullNode;
addChild(mClipCullNode);
osg::Camera::addChild(mClipCullNode);
SceneUtil::ShadowManager::disableShadowsForStateSet(getOrCreateStateSet());
}

@ -120,6 +120,9 @@ MWWorld::InventoryStore::InventoryStore (const InventoryStore& store)
MWWorld::InventoryStore& MWWorld::InventoryStore::operator= (const InventoryStore& store)
{
if (this == &store)
return *this;
mListener = store.mListener;
mInventoryListener = store.mInventoryListener;
mMagicEffects = store.mMagicEffects;

@ -76,7 +76,7 @@ void MWWorld::LocalScripts::startIteration()
bool MWWorld::LocalScripts::getNext(std::pair<std::string, Ptr>& script)
{
while (mIter!=mScripts.end())
if (mIter!=mScripts.end())
{
std::list<std::pair<std::string, Ptr> >::iterator iter = mIter++;
script = *iter;

@ -140,15 +140,12 @@ namespace Compiler
for (int i = 0; i <= length; i++)
{
if (length >= i)
{
in.get (ch);
in.get (ch);
if (!in.good())
return false;
if (!in.good())
return false;
mData[i] = ch;
}
mData[i] = ch;
}
mLength = length;

@ -21,7 +21,7 @@ namespace Files
LowLevelFile mFile;
char mBuffer[sBufferSize];
char mBuffer[sBufferSize]{0};
public:
ConstrainedFileStreamBuf(const std::string &fname, size_t start, size_t length)

@ -71,7 +71,7 @@ struct NiParticlesData : public NiGeometryData
{
int numParticles{0};
int activeCount;
int activeCount{0};
std::vector<float> particleRadii, sizes, rotationAngles;
std::vector<osg::Quat> rotations;
@ -119,14 +119,14 @@ struct NiPixelData : public Record
NIPXFMT_DXT5,
NIPXFMT_DXT5_ALT
};
Format fmt;
Format fmt{NIPXFMT_RGB8};
unsigned int colorMask[4];
unsigned int bpp, pixelTiling{0};
unsigned int colorMask[4]{0};
unsigned int bpp{0}, pixelTiling{0};
bool sRGB{false};
NiPalettePtr palette;
unsigned int numberOfMipmaps;
unsigned int numberOfMipmaps{0};
struct Mipmap
{

@ -177,7 +177,7 @@ struct Node : public Named
// NiNodes (or types derived from NiNodes) can be parents.
NiNode *parent;
bool isBone;
bool isBone{false};
void setBone()
{
@ -378,7 +378,7 @@ struct NiCamera : Node
struct NiSwitchNode : public NiNode
{
unsigned int switchFlags{0};
unsigned int initialIndex;
unsigned int initialIndex{0};
void read(NIFStream *nif) override
{

@ -61,7 +61,7 @@ struct NiTexturingProperty : public Property
3 - hilight // These two are for PS2 only?
4 - hilight2
*/
unsigned int apply;
unsigned int apply{0};
/*
* The textures in this list are as follows:
@ -193,7 +193,7 @@ struct S_MaterialProperty
// The vector components are R,G,B
osg::Vec3f ambient{1.f,1.f,1.f}, diffuse{1.f,1.f,1.f};
osg::Vec3f specular, emissive;
float glossiness, alpha;
float glossiness{0.f}, alpha{0.f};
void read(NIFStream *nif);
};

@ -785,6 +785,7 @@ MWShadowTechnique::MWShadowTechnique():
_debugHud(nullptr)
{
_shadowRecievingPlaceholderStateSet = new osg::StateSet;
mSetDummyStateWhenDisabled = false;
}
MWShadowTechnique::MWShadowTechnique(const MWShadowTechnique& vdsm, const osg::CopyOp& copyop):
@ -792,6 +793,7 @@ MWShadowTechnique::MWShadowTechnique(const MWShadowTechnique& vdsm, const osg::C
{
_shadowRecievingPlaceholderStateSet = new osg::StateSet;
_enableShadows = vdsm._enableShadows;
mSetDummyStateWhenDisabled = vdsm.mSetDummyStateWhenDisabled;
}
MWShadowTechnique::~MWShadowTechnique()

@ -78,7 +78,7 @@ void TerrainDrawable::cull(osgUtil::CullVisitor *cv)
osg::RefMatrix& matrix = *cv->getModelViewMatrix();
if (cv->getComputeNearFarMode() && bb.valid())
if (cv->getComputeNearFarMode() != osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR && bb.valid())
{
if (!cv->updateCalculatedNearFar(matrix, *this, false))
return;

@ -286,7 +286,7 @@ namespace ICS
//ControlAxisBinderItem joystickBinderItem = mControlsJoystickAxisBinderMap[ evt.which ][ axis ]; // joystic axis start at 0 index
//Control* ctrl = joystickBinderItem.control;
//if(ctrl && ctrl->isAxisBindable())
if(mDetectingBindingControl && mDetectingBindingControl->isAxisBindable())
if(mDetectingBindingControl->isAxisBindable())
{
if( abs( evt.value ) > ICS_JOYSTICK_AXIS_BINDING_MARGIN)
{

Loading…
Cancel
Save