MCPcopy Create free account
hub / github.com/MyGUI/mygui / startApp

Function startApp

Common/Base/Main.h:44–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42
43template<class AppClass>
44int startApp()
45{
46 try
47 {
48#if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32
49 // set working directory to exe location
50 LPSTR fileName = new CHAR[256];
51 GetModuleFileName(nullptr, fileName, 256);
52 std::string_view path = fileName;
53 size_t path_directory_index = path.find_last_of('\\');
54 std::string exedir{path.substr(0, path_directory_index + 1)};
55 _chdir(exedir.c_str());
56#endif
57
58 AppClass* app = new AppClass();
59 app->prepare();
60 if (app->create())
61 {
62#ifdef EMSCRIPTEN
63 emscripten_set_main_loop_arg(run<AppClass>, app, 120, true);
64#else
65 app->run();
66#endif
67 app->destroy();
68 }
69 delete app;
70 app = nullptr;
71 }
72 catch (MyGUI::Exception& _e)
73 {
74#if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32
75 MessageBoxA(
76 nullptr,
77 _e.getFullDescription().c_str(),
78 "An exception has occured",
79 MB_OK | MB_ICONERROR | MB_TASKMODAL);
80#else
81 std::cerr << "An exception has occured"
82 << " : " << _e.getFullDescription().c_str();
83#endif
84 throw;
85 }
86 return 0;
87}
88
89#endif

Callers

nothing calls this directly

Calls 7

find_last_ofMethod · 0.80
substrMethod · 0.80
runMethod · 0.80
c_strMethod · 0.45
prepareMethod · 0.45
createMethod · 0.45
destroyMethod · 0.45

Tested by

no test coverage detected