Fixed several errors reported by Valgrind.

This commit is contained in:
Leon Styhre 2020-10-11 18:57:37 +02:00
parent c2b3b029e5
commit 2768380446
8 changed files with 24 additions and 7 deletions

View file

@ -65,7 +65,15 @@ You can then profile the code with valgrind:
valgrind --tool=callgrind ./emulationstation
```
The output file from valgrind can be loaded into a tool such as KCachegrind for data analysis.
The output file can be loaded into a tool such as KCachegrind for data analysis.
To check for memory leaks, the following command is useful:
```
valgrind --tool=memcheck --leak-check=full ./emulationstation
```
Note that you can also profile either a normal build or a debug build, but it's recommended to use the profiling build for reasons that is beyond the scope of this document.
To build ES with CEC support, add the corresponding option, for example:

View file

@ -98,6 +98,13 @@ CollectionSystemManager::~CollectionSystemManager()
saveCustomCollection(it->second.system);
delete it->second.system;
}
// Delete the auto collections systems.
for (auto it = mAutoCollectionSystemsData.cbegin();
it != mAutoCollectionSystemsData.cend(); it++) {
delete (*it).second.system;
}
sInstance = nullptr;
}

View file

@ -49,7 +49,8 @@ GuiMetaDataEd::GuiMetaDataEd(
mMetaData(md),
mSavedCallback(saveCallback),
mClearGameFunc(clearGameFunc),
mDeleteGameFunc(deleteGameFunc)
mDeleteGameFunc(deleteGameFunc),
mMediaFilesUpdated(false)
{
addChild(&mBackground);
addChild(&mGrid);

View file

@ -466,7 +466,7 @@ int main(int argc, char* argv[])
bool splashScreen = Settings::getInstance()->getBool("SplashScreen");
bool splashScreenProgress = Settings::getInstance()->getBool("SplashScreenProgress");
SDL_Event event;
SDL_Event event {};
if (!window.init()) {
LOG(LogError) << "Window failed to initialize.";

View file

@ -16,6 +16,7 @@ SwitchComponent::SwitchComponent(
: GuiComponent(window),
mImage(window),
mState(state),
mOriginalValue(state),
mColorOriginalValue(DEFAULT_COLORSHIFT),
mColorChangedValue(DEFAULT_COLORSHIFT)
{

View file

@ -74,6 +74,7 @@ VideoComponent::VideoComponent(
mGameLaunched(false),
mBlockPlayer(false),
mTargetIsMax(false),
mFadeIn(1.0),
mTargetSize(0, 0)
{
// Setup the default configuration.

View file

@ -108,7 +108,6 @@ protected:
unsigned mVideoHeight;
Vector2f mTargetSize;
std::shared_ptr<TextureResource> mTexture;
float mFadeIn; // Used for fading in the video screensaver.
std::string mStaticImagePath;
ImageComponent mStaticImage;
@ -125,6 +124,7 @@ protected:
bool mGameLaunched;
bool mBlockPlayer;
bool mTargetIsMax;
float mFadeIn; // Used for fading in the video screensaver.
Configuration mConfig;
};

View file

@ -51,10 +51,8 @@ static void display(void* /*data*/, void* /*id*/) {
}
VideoVlcComponent::VideoVlcComponent(Window* window, std::string subtitles)
: VideoComponent(window), mMediaPlayer(nullptr)
: VideoComponent(window), mMediaPlayer(nullptr), mContext({})
{
memset(&mContext, 0, sizeof(mContext));
// Get an empty texture for rendering the video.
mTexture = TextureResource::get("");
@ -65,6 +63,7 @@ VideoVlcComponent::VideoVlcComponent(Window* window, std::string subtitles)
VideoVlcComponent::~VideoVlcComponent()
{
stopVideo();
mTexture.reset();
}
void VideoVlcComponent::setResize(float width, float height)