From 8ded41bb98068c5f49cdf0f3a652df041dbf1e4a Mon Sep 17 00:00:00 2001 From: Toshi Nagata Date: Tue, 25 Jan 2022 00:13:07 +0900 Subject: [PATCH] The batch mode crashes if Ruby exception was raised. Fixed. --- wxSources/MyApp.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/wxSources/MyApp.cpp b/wxSources/MyApp.cpp index 460ce6f..bc9501c 100755 --- a/wxSources/MyApp.cpp +++ b/wxSources/MyApp.cpp @@ -200,12 +200,20 @@ bool MyApp::Initialize(int& argc, wxChar **argv) { // Called with a batch mode? if (argc > 1 && wcscmp(argv[1], L"-b") == 0) { + + // Disable any wxLog functionality (otherwise ::exit() may crash) + wxLog::EnableLogging(false); + gUseGUI = 0; gSuppressConsole = 1; if (argc > 2 && wcscmp(argv[2], L"-v") == 0) gSuppressConsole = 0; - + + // We need these parameters in FindResourcePath(), so we assign them here + this->argc = argc; + this->argv = argv; + static const char fname[] = "startup.rb"; wxString dirname = FindResourcePath(); @@ -246,9 +254,9 @@ bool MyApp::Initialize(int& argc, wxChar **argv) } if (status != 0) { Ruby_showError(status); - ::exit(1); } - ::exit(0); + // Force exit + ::exit(status); } else { // Call the inherited version return wxApp::Initialize(argc, argv); -- 2.11.0