Segmentation fault

This commit is contained in:
2023-05-07 18:08:36 +02:00
parent 90ebea4807
commit c1f8e16963
17 changed files with 163 additions and 73 deletions

View File

@@ -6,6 +6,8 @@
// Constructor
Notify::Notify(SDL_Renderer *renderer, string iconFile, string bitmapFile, string textFile, string soundFile, options_t *options)
{
//std::cout << "Construido Notify" << std::endl;
// Inicializa variables
this->renderer = renderer;
this->options = options;
@@ -21,15 +23,29 @@ Notify::Notify(SDL_Renderer *renderer, string iconFile, string bitmapFile, strin
// Destructor
Notify::~Notify()
{
//std::cout << "Destruido Notify" << std::endl;
// Libera la memoria de los objetos
delete iconTexture;
delete text;
if (iconTexture != nullptr)
{
delete iconTexture;
}
if (text != nullptr)
{
delete text;
}
JA_DeleteSound(sound);
for (auto notification : notifications)
{
delete notification.sprite;
delete notification.texture;
if (notification.sprite != nullptr)
{
delete notification.sprite;
}
if (notification.texture != nullptr)
{
delete notification.texture;
}
}
}
@@ -116,8 +132,14 @@ void Notify::clearFinishedNotifications()
{
if (notifications[i].state == ns_finished)
{
delete notifications[i].sprite;
delete notifications[i].texture;
if (notifications[i].sprite != nullptr)
{
delete notifications[i].sprite;
}
if (notifications[i].texture != nullptr)
{
delete notifications[i].texture;
}
notifications.erase(notifications.begin() + i);
}
}