Some (defined out) startup logging code.

Originally committed to SVN as r1381.
This commit is contained in:
Niels Martin Hansen 2007-07-05 19:11:54 +00:00
parent a9df544cee
commit 6d55d1fa11
1 changed files with 29 additions and 0 deletions

View File

@ -68,16 +68,34 @@
IMPLEMENT_APP(AegisubApp) IMPLEMENT_APP(AegisubApp)
#if 0
void StartupLog(const wxString &msg) {
static wxStopWatch clock;
wxString nmsg = wxString::Format(_T("Startup: %d - %s\n"), clock.Time(), msg.c_str());
#ifdef WIN32
OutputDebugStringW(nmsg.wc_str());
#else
printf(nmsg.mb_str(wxConvLocal));
#endif
}
#else
#define StartupLog(a)
#endif
/////////////////////////// ///////////////////////////
// Initialization function // Initialization function
// ----------------------- // -----------------------
// Gets called when application starts, creates MainFrame // Gets called when application starts, creates MainFrame
bool AegisubApp::OnInit() { bool AegisubApp::OnInit() {
StartupLog(_T("Inside OnInit"));
try { try {
// Initialize randomizer // Initialize randomizer
StartupLog(_T("Initialize random generator"));
srand(time(NULL)); srand(time(NULL));
// locale for loading options // locale for loading options
StartupLog(_T("Set initial locale"));
setlocale(LC_NUMERIC, "C"); setlocale(LC_NUMERIC, "C");
setlocale(LC_CTYPE, "C"); setlocale(LC_CTYPE, "C");
@ -94,10 +112,12 @@ bool AegisubApp::OnInit() {
// Crash handling // Crash handling
#ifndef _DEBUG #ifndef _DEBUG
StartupLog(_T("Install exception handler"));
wxHandleFatalExceptions(true); wxHandleFatalExceptions(true);
#endif #endif
// Set config file // Set config file
StartupLog(_T("Load configuration"));
Options.SetFile(StandardPaths::DecodePath(_T("?data/config.dat"))); Options.SetFile(StandardPaths::DecodePath(_T("?data/config.dat")));
Options.LoadDefaults(); Options.LoadDefaults();
Options.Load(); Options.Load();
@ -106,13 +126,16 @@ bool AegisubApp::OnInit() {
Options.Load(); Options.Load();
wxRemoveFile(StandardPaths::DecodePath(_T("?data/config.dat"))); wxRemoveFile(StandardPaths::DecodePath(_T("?data/config.dat")));
} }
StartupLog(_T("Store options back"));
Options.Save(); Options.Save();
AssTime::UseMSPrecision = Options.AsBool(_T("Use nonstandard Milisecond Times")); AssTime::UseMSPrecision = Options.AsBool(_T("Use nonstandard Milisecond Times"));
// Set hotkeys file // Set hotkeys file
StartupLog(_T("Load hotkeys"));
Hotkeys.SetFile(StandardPaths::DecodePath(_T("?user/hotkeys.dat"))); Hotkeys.SetFile(StandardPaths::DecodePath(_T("?user/hotkeys.dat")));
Hotkeys.Load(); Hotkeys.Load();
StartupLog(_T("Initialize final locale"));
#ifdef __WINDOWS__ #ifdef __WINDOWS__
// Set locale // Set locale
int lang = Options.AsInt(_T("Locale Code")); int lang = Options.AsInt(_T("Locale Code"));
@ -128,22 +151,27 @@ bool AegisubApp::OnInit() {
// Set association // Set association
#ifndef _DEBUG #ifndef _DEBUG
StartupLog(_T("Install file type associations"));
RegistryAssociate(); RegistryAssociate();
#endif #endif
// Load Automation scripts // Load Automation scripts
StartupLog(_T("Load global Automation scripts"));
global_scripts = new Automation4::AutoloadScriptManager(Options.AsText(_T("Automation Autoload Path"))); global_scripts = new Automation4::AutoloadScriptManager(Options.AsText(_T("Automation Autoload Path")));
// Load export filters // Load export filters
StartupLog(_T("Prepare export filters"));
AssExportFilterChain::PrepareFilters(); AssExportFilterChain::PrepareFilters();
// Get parameter subs // Get parameter subs
StartupLog(_T("Parse command line"));
wxArrayString subs; wxArrayString subs;
for (int i=1;i<argc;i++) { for (int i=1;i<argc;i++) {
subs.Add(argv[i]); subs.Add(argv[i]);
} }
// Open main frame // Open main frame
StartupLog(_T("Create main window"));
frame = new FrameMain(subs); frame = new FrameMain(subs);
SetTopWindow(frame); SetTopWindow(frame);
} }
@ -158,6 +186,7 @@ bool AegisubApp::OnInit() {
return false; return false;
} }
StartupLog(_T("Initialization complete"));
return true; return true;
} }