mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 10:40:46 +00:00
-perform a proper exit, i.e. make sure that the deinit code can run, by throwing a special exception and actually catching it in the main function.
This commit is contained in:
parent
0d878a8604
commit
1c29169492
5 changed files with 29 additions and 20 deletions
|
@ -793,7 +793,6 @@ void CONFIG_WriteSetup(uint32_t flags)
|
|||
|
||||
OSD_Printf("Wrote %s\n",SetupFilename);
|
||||
CONFIG_WriteSettings();
|
||||
G_SaveConfig();
|
||||
Bfflush(NULL);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -652,11 +652,18 @@ static FORCE_INLINE int32_t Blrintf(const float x)
|
|||
# define ERRprintf(fmt, ...) fprintf(stderr, fmt, ## __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUGGINGAIDS
|
||||
# define Bexit(status) do { initprintf("exit(%d) at %s:%d in %s()\n", status, __FILE__, __LINE__, EDUKE32_FUNCTION); exit(status); } while (0)
|
||||
#else
|
||||
# define Bexit(a) exit(a)// throw(1)
|
||||
#endif
|
||||
class ExitEvent : public std::exception
|
||||
{
|
||||
int reason;
|
||||
public:
|
||||
ExitEvent(int a) { reason = a; }
|
||||
int Reason() const { return reason; }
|
||||
};
|
||||
|
||||
inline void Bexit(int a)
|
||||
{
|
||||
throw ExitEvent(a);
|
||||
}
|
||||
|
||||
|
||||
////////// Standard library monkey patching //////////
|
||||
|
|
|
@ -538,9 +538,6 @@ int WINAPI WinMain(HINSTANCE , HINSTANCE , LPSTR , int )
|
|||
int main(int argc, char *argv[])
|
||||
#endif
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
#ifdef _WIN32
|
||||
char* argvbuf;
|
||||
int32_t buildargc = win_buildargs(&argvbuf);
|
||||
|
@ -597,8 +594,23 @@ int main(int argc, char *argv[])
|
|||
|
||||
startwin_open();
|
||||
|
||||
G_LoadConfig(currentGame);
|
||||
r = gi->app_main(buildargc, (const char **)buildargv);
|
||||
try
|
||||
{
|
||||
|
||||
G_LoadConfig(currentGame);
|
||||
r = gi->app_main(buildargc, (const char**)buildargv);
|
||||
}
|
||||
catch (const std::runtime_error & err)
|
||||
{
|
||||
wm_msgbox("Error", "%s", err.what());
|
||||
return 3;
|
||||
}
|
||||
catch (const ExitEvent & exit)
|
||||
{
|
||||
// Just let the rest of the function execute.
|
||||
r = exit.Reason();
|
||||
}
|
||||
G_SaveConfig();
|
||||
|
||||
startwin_close();
|
||||
|
||||
|
@ -606,13 +618,6 @@ int main(int argc, char *argv[])
|
|||
gtkbuild_exit(r);
|
||||
#endif
|
||||
return r;
|
||||
}
|
||||
catch(std::runtime_error &err)
|
||||
{
|
||||
wm_msgbox("Error", "%s", err.what());
|
||||
return 3;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -946,7 +946,6 @@ void CONFIG_WriteSetup(uint32_t flags)
|
|||
|
||||
OSD_Printf("Wrote %s\n",g_setupFileName);
|
||||
CONFIG_WriteSettings();
|
||||
G_SaveConfig();
|
||||
Bfflush(NULL);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -748,7 +748,6 @@ void CONFIG_WriteSetup(uint32_t flags)
|
|||
|
||||
OSD_Printf("Wrote %s\n",g_setupFileName);
|
||||
CONFIG_WriteSettings();
|
||||
G_SaveConfig();
|
||||
Bfflush(NULL);
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue