Skip to content

Commit 42f5d4f

Browse files
authored
Add printLeaks call in appropriate location to help developers (#2275)
Add the printLeaks call in the correct location to help developers locate leaks in their apps if leak detection is enabled
1 parent 56b1d76 commit 42f5d4f

File tree

4 files changed

+44
-6
lines changed

4 files changed

+44
-6
lines changed

templates/common/proj.ios_mac/mac/main.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,20 @@
2929

3030
using namespace ax;
3131

32-
int main(int argc, char* argv[])
32+
int axmol_main()
3333
{
34+
// create the application instance
3435
AppDelegate app;
3536
return Application::getInstance()->run();
3637
}
38+
39+
int main(int argc, char* argv[])
40+
{
41+
auto result = axmol_main();
42+
43+
#if AX_OBJECT_LEAK_DETECTION
44+
Object::printLeaks();
45+
#endif
46+
47+
return result;
48+
}

templates/common/proj.linux/main.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,20 @@
3232

3333
using namespace ax;
3434

35-
int main(int argc, char** argv)
35+
int axmol_main()
3636
{
3737
// create the application instance
3838
AppDelegate app;
3939
return Application::getInstance()->run();
4040
}
41+
42+
int main(int argc, char** argv)
43+
{
44+
auto result = axmol_main();
45+
46+
#if AX_OBJECT_LEAK_DETECTION
47+
Object::printLeaks();
48+
#endif
49+
50+
return result;
51+
}

templates/common/proj.wasm/main.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,20 @@
3333

3434
using namespace ax;
3535

36-
int main(int argc, char** argv)
36+
int axmol_main()
3737
{
3838
// create the application instance
3939
AppDelegate app;
4040
return Application::getInstance()->run();
4141
}
42+
43+
int main(int argc, char** argv)
44+
{
45+
auto result = axmol_main();
46+
47+
#if AX_OBJECT_LEAK_DETECTION
48+
Object::printLeaks();
49+
#endif
50+
51+
return result;
52+
}

templates/common/proj.win32/main.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,17 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdL
4545
UNREFERENCED_PARAMETER(hPrevInstance);
4646
UNREFERENCED_PARAMETER(lpCmdLine);
4747

48-
// create the application instance
4948
#ifdef USE_WIN32_CONSOLE
5049
# include "platform/win32/EmbedConsole.h"
5150
#endif
5251

53-
// create the application instance
54-
return axmol_main();
52+
auto result = axmol_main();
53+
54+
#if AX_OBJECT_LEAK_DETECTION
55+
Object::printLeaks();
56+
#endif
57+
58+
return result;
5559
}
5660
#else
5761
int main(int, char**) {

0 commit comments

Comments
 (0)