Skip to content

Commit

Permalink
Merge branch 'main' into gabriel_dev
Browse files Browse the repository at this point in the history
  • Loading branch information
paxo-rch authored Sep 2, 2024
2 parents a152c62 + b272417 commit 192ade4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
6 changes: 6 additions & 0 deletions lib/gui/src/ElementBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ gui::ElementBase::ElementBase() : m_x(0), m_y(0),

gui::ElementBase::~ElementBase()
{
if (m_parent != nullptr)
m_parent->localGraphicalUpdate();

// Libération de la mémoire allouée pour les enfants de l'objet
for (int i = 0; i < m_children.size(); i++)
{
Expand Down Expand Up @@ -124,6 +127,9 @@ bool gui::ElementBase::updateAll()

for (auto child : m_children)
{
if (!child->getIsEnabled())
continue;

if (child->updateAll())
{
returnV = true; // if child had an event, ignore local events
Expand Down
7 changes: 7 additions & 0 deletions lib/lua/src/lua_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ LuaFile::LuaFile(storage::Path filename, storage::Path manifest)

LuaFile::~LuaFile()
{
// prevent a crash if the app is deleted and one or more callbacks are defined
this->onmessage = sol::nil;
this->onmessageerror = sol::nil;
this->oncall = sol::nil;
this->onlowbattery = sol::nil;
this->oncharging = sol::nil;

// libérer les ressources (events, etc)
}

Expand Down
6 changes: 3 additions & 3 deletions lib/lua/src/lua_file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ class LuaFile

void event_onmessageerror()
{
if(onmessage.valid()) {
if(onmessageerror.valid()) {
sol::protected_function_result result = onmessageerror();
if (!result.valid()) {
sol::error err = result;
std::cout << "[LuaFile] onmessage event error: " << err.what() << std::endl;
std::cout << "[LuaFile] onmessageerror event error: " << err.what() << std::endl;
} else {
std::cout << "onmessage event activated" << std::endl;
std::cout << "onmessageerror event activated" << std::endl;
}
}
}
Expand Down

0 comments on commit 192ade4

Please sign in to comment.