1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-19 23:23:52 +00:00

Merge remote-tracking branch 'lgro/valgrind_warnings'

This commit is contained in:
Marc Zinnschlag 2014-01-01 19:41:52 +01:00
commit e1355be47c
17 changed files with 128 additions and 24 deletions

View file

@ -55,6 +55,8 @@ namespace MWGui
, mWorldMouseOver(false) , mWorldMouseOver(false)
, mEnemyHealthTimer(0) , mEnemyHealthTimer(0)
, mIsDrowning(false) , mIsDrowning(false)
, mWeaponSpellTimer(0.f)
, mDrowningFlashTheta(0.f)
{ {
setCoord(0,0, width, height); setCoord(0,0, width, height);

View file

@ -16,6 +16,15 @@ namespace MWGui
mLastButtonPressed = -1; mLastButtonPressed = -1;
} }
MessageBoxManager::~MessageBoxManager ()
{
std::vector<MessageBox*>::iterator it(mMessageBoxes.begin());
for (; it != mMessageBoxes.end(); ++it)
{
delete *it;
}
}
void MessageBoxManager::onFrame (float frameDuration) void MessageBoxManager::onFrame (float frameDuration)
{ {
std::vector<MessageBox*>::iterator it; std::vector<MessageBox*>::iterator it;

View file

@ -23,6 +23,7 @@ namespace MWGui
{ {
public: public:
MessageBoxManager (); MessageBoxManager ();
~MessageBoxManager ();
void onFrame (float frameDuration); void onFrame (float frameDuration);
void createMessageBox (const std::string& message, bool stat = false); void createMessageBox (const std::string& message, bool stat = false);
void removeStaticMessageBox (); void removeStaticMessageBox ();

View file

@ -323,6 +323,7 @@ namespace MWGui
delete mSoulgemDialog; delete mSoulgemDialog;
delete mCursorManager; delete mCursorManager;
delete mRecharge; delete mRecharge;
delete mCompanionWindow;
cleanupGarbage(); cleanupGarbage();

View file

@ -537,6 +537,16 @@ namespace MWMechanics
Actors::Actors() {} Actors::Actors() {}
Actors::~Actors()
{
PtrControllerMap::iterator it(mActors.begin());
for (; it != mActors.end(); ++it)
{
delete it->second;
it->second = NULL;
}
}
void Actors::addActor (const MWWorld::Ptr& ptr) void Actors::addActor (const MWWorld::Ptr& ptr)
{ {
// erase previous death events since we are currently only tracking them while in an active cell // erase previous death events since we are currently only tracking them while in an active cell

View file

@ -48,6 +48,7 @@ namespace MWMechanics
public: public:
Actors(); Actors();
~Actors();
/// Update magic effects for an actor. Usually done automatically once per frame, but if we're currently /// Update magic effects for an actor. Usually done automatically once per frame, but if we're currently
/// paused we may want to do it manually (after equipping permanent enchantment) /// paused we may want to do it manually (after equipping permanent enchantment)

View file

@ -14,6 +14,16 @@ Objects::Objects()
{ {
} }
Objects::~Objects()
{
PtrControllerMap::iterator it(mObjects.begin());
for (; it != mObjects.end();++it)
{
delete it->second;
it->second = NULL;
}
}
void Objects::addObject(const MWWorld::Ptr& ptr) void Objects::addObject(const MWWorld::Ptr& ptr)
{ {
removeObject(ptr); removeObject(ptr);

View file

@ -21,6 +21,7 @@ namespace MWMechanics
public: public:
Objects(); Objects();
~Objects();
void addObject (const MWWorld::Ptr& ptr); void addObject (const MWWorld::Ptr& ptr);
///< Register an animated object ///< Register an animated object

View file

@ -19,25 +19,27 @@ namespace MWRender
Camera::Camera (Ogre::Camera *camera) Camera::Camera (Ogre::Camera *camera)
: mCamera(camera), : mCamera(camera),
mCameraNode(NULL), mCameraNode(NULL),
mAnimation(NULL),
mFirstPersonView(true), mFirstPersonView(true),
mPreviewMode(false), mPreviewMode(false),
mFreeLook(true), mFreeLook(true),
mHeight(128.f),
mCameraDistance(300.f),
mDistanceAdjusted(false),
mAnimation(NULL),
mNearest(30.f), mNearest(30.f),
mFurthest(800.f), mFurthest(800.f),
mIsNearest(false), mIsNearest(false),
mIsFurthest(false), mIsFurthest(false),
mHeight(128.f),
mCameraDistance(300.f),
mDistanceAdjusted(false),
mVanityToggleQueued(false), mVanityToggleQueued(false),
mViewModeToggleQueued(false) mViewModeToggleQueued(false)
{ {
mVanity.enabled = false; mVanity.enabled = false;
mVanity.allowed = true; mVanity.allowed = true;
mPreviewCam.pitch = 0.f;
mPreviewCam.yaw = 0.f; mPreviewCam.yaw = 0.f;
mPreviewCam.offset = 400.f; mPreviewCam.offset = 400.f;
mMainCam.pitch = 0.f;
mMainCam.yaw = 0.f; mMainCam.yaw = 0.f;
mMainCam.offset = 400.f; mMainCam.offset = 400.f;
} }

View file

@ -949,9 +949,25 @@ void VideoState::init(const std::string& resourceName)
this->format_ctx->pb = ioCtx; this->format_ctx->pb = ioCtx;
// Open video file // Open video file
/// \todo leak here, ffmpeg or valgrind bug ? ///
/// format_ctx->pb->buffer must be freed by hand,
/// if not, valgrind will show memleak, see:
///
/// https://trac.ffmpeg.org/ticket/1357
///
if(!this->format_ctx || avformat_open_input(&this->format_ctx, resourceName.c_str(), NULL, NULL)) if(!this->format_ctx || avformat_open_input(&this->format_ctx, resourceName.c_str(), NULL, NULL))
{ {
if (this->format_ctx != NULL)
{
if (this->format_ctx->pb != NULL)
{
av_free(this->format_ctx->pb->buffer);
this->format_ctx->pb->buffer = NULL;
av_free(this->format_ctx->pb);
this->format_ctx->pb = NULL;
}
}
// "Note that a user-supplied AVFormatContext will be freed on failure." // "Note that a user-supplied AVFormatContext will be freed on failure."
this->format_ctx = NULL; this->format_ctx = NULL;
av_free(ioCtx); av_free(ioCtx);
@ -1009,9 +1025,21 @@ void VideoState::deinit()
if(this->format_ctx) if(this->format_ctx)
{ {
AVIOContext *ioContext = this->format_ctx->pb; ///
/// format_ctx->pb->buffer must be freed by hand,
/// if not, valgrind will show memleak, see:
///
/// https://trac.ffmpeg.org/ticket/1357
///
if (this->format_ctx->pb != NULL)
{
av_free(this->format_ctx->pb->buffer);
this->format_ctx->pb->buffer = NULL;
av_free(this->format_ctx->pb);
this->format_ctx->pb = NULL;;
}
avformat_close_input(&this->format_ctx); avformat_close_input(&this->format_ctx);
av_free(ioContext);
} }
} }

View file

@ -292,6 +292,7 @@ Water::~Water()
delete mReflection; delete mReflection;
delete mRefraction; delete mRefraction;
delete mSimulation;
} }
void Water::changeCell(const ESM::Cell* cell) void Water::changeCell(const ESM::Cell* cell)

View file

@ -127,7 +127,6 @@ op 0x200007e-0x2000084: Enable Controls
op 0x2000085-0x200008b: Disable Controls op 0x2000085-0x200008b: Disable Controls
op 0x200008c: Unlock op 0x200008c: Unlock
op 0x200008d: Unlock, explicit reference op 0x200008d: Unlock, explicit reference
op 0x200008e: COE
op 0x200008e-0x20000a8: GetSkill op 0x200008e-0x20000a8: GetSkill
op 0x20000a9-0x20000c3: GetSkill, explicit reference op 0x20000a9-0x20000c3: GetSkill, explicit reference
op 0x20000c4-0x20000de: SetSkill op 0x20000c4-0x20000de: SetSkill
@ -358,5 +357,6 @@ op 0x2000222: GetLineOfSight
op 0x2000223: GetLineOfSightExplicit op 0x2000223: GetLineOfSightExplicit
op 0x2000224: ToggleAI op 0x2000224: ToggleAI
op 0x2000225: ToggleAIExplicit op 0x2000225: ToggleAIExplicit
op 0x2000226: COE
opcodes 0x2000226-0x3ffffff unused opcodes 0x2000227-0x3ffffff unused

View file

@ -158,6 +158,16 @@ void FFmpeg_Decoder::open(const std::string &fname)
mFormatCtx->pb = avio_alloc_context(NULL, 0, 0, this, readPacket, writePacket, seek); mFormatCtx->pb = avio_alloc_context(NULL, 0, 0, this, readPacket, writePacket, seek);
if(!mFormatCtx->pb || avformat_open_input(&mFormatCtx, fname.c_str(), NULL, NULL) != 0) if(!mFormatCtx->pb || avformat_open_input(&mFormatCtx, fname.c_str(), NULL, NULL) != 0)
{ {
if (mFormatCtx->pb != NULL)
{
if (mFormatCtx->pb->buffer != NULL)
{
av_free(mFormatCtx->pb->buffer);
mFormatCtx->pb->buffer = NULL;
}
av_free(mFormatCtx->pb);
mFormatCtx->pb = NULL;
}
avformat_free_context(mFormatCtx); avformat_free_context(mFormatCtx);
mFormatCtx = NULL; mFormatCtx = NULL;
fail("Failed to allocate input stream"); fail("Failed to allocate input stream");
@ -195,6 +205,14 @@ void FFmpeg_Decoder::open(const std::string &fname)
} }
catch(std::exception &e) catch(std::exception &e)
{ {
if (mFormatCtx->pb->buffer != NULL)
{
av_free(mFormatCtx->pb->buffer);
mFormatCtx->pb->buffer = NULL;
}
av_free(mFormatCtx->pb);
mFormatCtx->pb = NULL;
avformat_close_input(&mFormatCtx); avformat_close_input(&mFormatCtx);
throw; throw;
} }
@ -211,9 +229,22 @@ void FFmpeg_Decoder::close()
if(mFormatCtx) if(mFormatCtx)
{ {
AVIOContext* context = mFormatCtx->pb; if (mFormatCtx->pb != NULL)
{
// mFormatCtx->pb->buffer must be freed by hand,
// if not, valgrind will show memleak, see:
//
// https://trac.ffmpeg.org/ticket/1357
//
if (mFormatCtx->pb->buffer != NULL)
{
av_free(mFormatCtx->pb->buffer);
mFormatCtx->pb->buffer = NULL;
}
av_free(mFormatCtx->pb);
mFormatCtx->pb = NULL;
}
avformat_close_input(&mFormatCtx); avformat_close_input(&mFormatCtx);
av_free(context);
} }
mDataStream.setNull(); mDataStream.setNull();

View file

@ -25,7 +25,7 @@ namespace Compiler
const int opcodeAiFollowExplicit = 0x20023; const int opcodeAiFollowExplicit = 0x20023;
const int opcodeAiFollowCell = 0x20024; const int opcodeAiFollowCell = 0x20024;
const int opcodeAiFollowCellExplicit = 0x20025; const int opcodeAiFollowCellExplicit = 0x20025;
const int opcodeSetHello = 0x200015e; const int opcodeSetHello = 0x200015c;
const int opcodeSetHelloExplicit = 0x200015d; const int opcodeSetHelloExplicit = 0x200015d;
const int opcodeSetFight = 0x200015e; const int opcodeSetFight = 0x200015e;
const int opcodeSetFightExplicit = 0x200015f; const int opcodeSetFightExplicit = 0x200015f;
@ -69,7 +69,7 @@ namespace Compiler
{ {
const int opcodeCellChanged = 0x2000000; const int opcodeCellChanged = 0x2000000;
const int opcodeCOC = 0x2000026; const int opcodeCOC = 0x2000026;
const int opcodeCOE = 0x200008e; const int opcodeCOE = 0x2000226;
const int opcodeGetInterior = 0x2000131; const int opcodeGetInterior = 0x2000131;
const int opcodeGetPCCell = 0x2000136; const int opcodeGetPCCell = 0x2000136;
const int opcodeGetWaterLevel = 0x2000141; const int opcodeGetWaterLevel = 0x2000141;

View file

@ -166,31 +166,37 @@ namespace Interpreter
void Interpreter::installSegment0 (int code, Opcode1 *opcode) void Interpreter::installSegment0 (int code, Opcode1 *opcode)
{ {
assert(mSegment0.find(code) == mSegment0.end());
mSegment0.insert (std::make_pair (code, opcode)); mSegment0.insert (std::make_pair (code, opcode));
} }
void Interpreter::installSegment1 (int code, Opcode2 *opcode) void Interpreter::installSegment1 (int code, Opcode2 *opcode)
{ {
assert(mSegment1.find(code) == mSegment1.end());
mSegment1.insert (std::make_pair (code, opcode)); mSegment1.insert (std::make_pair (code, opcode));
} }
void Interpreter::installSegment2 (int code, Opcode1 *opcode) void Interpreter::installSegment2 (int code, Opcode1 *opcode)
{ {
assert(mSegment2.find(code) == mSegment2.end());
mSegment2.insert (std::make_pair (code, opcode)); mSegment2.insert (std::make_pair (code, opcode));
} }
void Interpreter::installSegment3 (int code, Opcode1 *opcode) void Interpreter::installSegment3 (int code, Opcode1 *opcode)
{ {
assert(mSegment3.find(code) == mSegment3.end());
mSegment3.insert (std::make_pair (code, opcode)); mSegment3.insert (std::make_pair (code, opcode));
} }
void Interpreter::installSegment4 (int code, Opcode2 *opcode) void Interpreter::installSegment4 (int code, Opcode2 *opcode)
{ {
assert(mSegment4.find(code) == mSegment4.end());
mSegment4.insert (std::make_pair (code, opcode)); mSegment4.insert (std::make_pair (code, opcode));
} }
void Interpreter::installSegment5 (int code, Opcode0 *opcode) void Interpreter::installSegment5 (int code, Opcode0 *opcode)
{ {
assert(mSegment5.find(code) == mSegment5.end());
mSegment5.insert (std::make_pair (code, opcode)); mSegment5.insert (std::make_pair (code, opcode));
} }

View file

@ -140,17 +140,19 @@ namespace
} }
QuadTreeNode::QuadTreeNode(World* terrain, ChildDirection dir, float size, const Ogre::Vector2 &center, QuadTreeNode* parent) QuadTreeNode::QuadTreeNode(World* terrain, ChildDirection dir, float size, const Ogre::Vector2 &center, QuadTreeNode* parent)
: mSize(size) : mMaterialGenerator(NULL)
, mCenter(center) , mIsActive(false)
, mParent(parent)
, mDirection(dir)
, mIsDummy(false) , mIsDummy(false)
, mSceneNode(NULL) , mSize(size)
, mTerrain(terrain) , mLodLevel(Log2(mSize))
, mChunk(NULL)
, mMaterialGenerator(NULL)
, mBounds(Ogre::AxisAlignedBox::BOX_NULL) , mBounds(Ogre::AxisAlignedBox::BOX_NULL)
, mWorldBounds(Ogre::AxisAlignedBox::BOX_NULL) , mWorldBounds(Ogre::AxisAlignedBox::BOX_NULL)
, mDirection(dir)
, mCenter(center)
, mSceneNode(NULL)
, mParent(parent)
, mTerrain(terrain)
, mChunk(NULL)
{ {
mBounds.setNull(); mBounds.setNull();
for (int i=0; i<4; ++i) for (int i=0; i<4; ++i)
@ -168,8 +170,6 @@ QuadTreeNode::QuadTreeNode(World* terrain, ChildDirection dir, float size, const
pos = mCenter - pos; pos = mCenter - pos;
mSceneNode->setPosition(Ogre::Vector3(pos.x*8192, pos.y*8192, 0)); mSceneNode->setPosition(Ogre::Vector3(pos.x*8192, pos.y*8192, 0));
mLodLevel = Log2(mSize);
mMaterialGenerator = new MaterialGenerator(mTerrain->getShadersEnabled()); mMaterialGenerator = new MaterialGenerator(mTerrain->getShadersEnabled());
} }

View file

@ -74,8 +74,9 @@ namespace OEngine
, mScene(NULL) , mScene(NULL)
, mCamera(NULL) , mCamera(NULL)
, mView(NULL) , mView(NULL)
, mWindowListener(NULL) , mOgreInit(NULL)
, mFader(NULL) , mFader(NULL)
, mWindowListener(NULL)
{ {
} }