diff --git a/src/E2wxApp.cpp b/src/E2wxApp.cpp index 264cc6b..32a6a66 100644 --- a/src/E2wxApp.cpp +++ b/src/E2wxApp.cpp @@ -25,10 +25,15 @@ #include "gui.h" #include "e2config.h" #include "e2filesystem.h" +#include "e2const.h" + #include #include #include +#include #include +#include + #include #include #include @@ -38,7 +43,7 @@ #include #include #include -#include + #include #include #include @@ -136,6 +141,14 @@ bool E2wxApp::OnInit() { InitBoostLog(); +// TODO investigate redirecting wxLogs to boost +// wxLog* logger = new wxLogStream(&std::cerr); +// wxLog::SetActiveTarget(logger); +// wxLogWarning("%s", "a warning has occurred"); +// wxLogInfo("%s", "informational"); +// wxLogVerbose("%s", "verbose"); +// wxFile().Open("foobar.txt"); + BOOST_LOG_TRIVIAL(info) << "Application ID: " << this->GetID(); BOOST_LOG_TRIVIAL(info) << "Application version: " << this->GetVersion(); @@ -228,6 +241,7 @@ void E2wxApp::OnFatalException() { static const wxCmdLineEntryDesc cmdLineDesc[] = { { wxCMD_LINE_SWITCH, "p", "prefs", "Read config only from preferences, never an external file.", wxCMD_LINE_VAL_NONE }, + { wxCMD_LINE_SWITCH, "t", "test", "Run internal tests.", wxCMD_LINE_VAL_NONE }, { wxCMD_LINE_PARAM, NULL, NULL, "config-file", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, wxCMD_LINE_DESC_END }; @@ -242,6 +256,16 @@ bool E2wxApp::OnCmdLineParsed(wxCmdLineParser& parser) { return false; } + if (parser.Found("t")) { + const int x = E2Const::test(); + if (x != -1) { + std::cerr << x << std::endl; + throw std::runtime_error("bad constant in e2const.h" ); + } + std::cerr << "pass" << std::endl; + return false; + } + this->opt_config_from_prefs_only = parser.Found("p"); const int n = parser.GetParamCount(); diff --git a/src/emulator.cpp b/src/emulator.cpp index 06d79d7..a5d662c 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -471,9 +471,6 @@ bool Emulator::isSafeToQuit() { return true; } -// we come here due to F9 or SQL_Quit event void Emulator::handleUserQuitRequest() { wxGetApp().CloseMainFrame(); - // wxWidgets will then call us back with isSafeToQuit, and if so will exit the application - // (note wxWidgets will also need to call us back when it gets it's own quit requests) } diff --git a/src/main.cpp b/src/main.cpp index 84060f7..ff951e1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,16 +18,8 @@ */ #include "gui.h" -#include "e2const.h" - #include - #include - -#include -#include -#include - #include @@ -38,12 +30,6 @@ int main(int argc, char *argv[]) { ::setbuf(stdout, nullptr); ::setbuf(stderr, nullptr); - const int x = E2Const::test(); - if (x != -1) { - std::cerr << x << std::endl; - throw std::runtime_error("bad constant in e2const.h" ); - } - GUI gui; return wxEntry(argc, argv);