Skip to content

Commit

Permalink
Add printLeaks call in appropriate location to help developers (#2275)
Browse files Browse the repository at this point in the history
Add the printLeaks call in the correct location to help developers locate leaks in their apps if leak detection is enabled
  • Loading branch information
rh101 authored Dec 14, 2024
1 parent 56b1d76 commit 42f5d4f
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 6 deletions.
14 changes: 13 additions & 1 deletion templates/common/proj.ios_mac/mac/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,20 @@

using namespace ax;

int main(int argc, char* argv[])
int axmol_main()
{
// create the application instance
AppDelegate app;
return Application::getInstance()->run();
}

int main(int argc, char* argv[])
{
auto result = axmol_main();

#if AX_OBJECT_LEAK_DETECTION
Object::printLeaks();
#endif

return result;
}
13 changes: 12 additions & 1 deletion templates/common/proj.linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,20 @@

using namespace ax;

int main(int argc, char** argv)
int axmol_main()
{
// create the application instance
AppDelegate app;
return Application::getInstance()->run();
}

int main(int argc, char** argv)
{
auto result = axmol_main();

#if AX_OBJECT_LEAK_DETECTION
Object::printLeaks();
#endif

return result;
}
13 changes: 12 additions & 1 deletion templates/common/proj.wasm/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,20 @@

using namespace ax;

int main(int argc, char** argv)
int axmol_main()
{
// create the application instance
AppDelegate app;
return Application::getInstance()->run();
}

int main(int argc, char** argv)
{
auto result = axmol_main();

#if AX_OBJECT_LEAK_DETECTION
Object::printLeaks();
#endif

return result;
}
10 changes: 7 additions & 3 deletions templates/common/proj.win32/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,17 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdL
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);

// create the application instance
#ifdef USE_WIN32_CONSOLE
# include "platform/win32/EmbedConsole.h"
#endif

// create the application instance
return axmol_main();
auto result = axmol_main();

#if AX_OBJECT_LEAK_DETECTION
Object::printLeaks();
#endif

return result;
}
#else
int main(int, char**) {
Expand Down

0 comments on commit 42f5d4f

Please sign in to comment.