2006-01-16 22:02:54 +01:00
// Copyright (c) 2005, Rodrigo Braz Monteiro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of the Aegisub Group nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
2009-07-29 07:43:02 +02:00
// Aegisub Project http://www.aegisub.org/
2006-01-16 22:02:54 +01:00
//
2009-07-29 07:43:02 +02:00
// $Id$
/// @file main.cpp
/// @brief Main entry point, as well as crash handling
/// @ingroup main
///
2006-01-16 22:02:54 +01:00
////////////
// Includes
2009-01-04 07:31:48 +01:00
# include "config.h"
2009-09-10 06:14:28 +02:00
# ifndef AGI_PRE
2006-01-16 22:02:54 +01:00
# include <wx/config.h>
2009-09-10 04:07:55 +02:00
# include <wx/datetime.h>
# include <wx/filefn.h>
2006-01-16 22:02:54 +01:00
# include <wx/filename.h>
2007-01-07 23:54:04 +01:00
# include <wx/mimetype.h>
2009-09-10 04:07:55 +02:00
# include <wx/msgdlg.h>
2007-06-21 02:46:50 +02:00
# include <wx/stdpaths.h>
2009-09-10 04:07:55 +02:00
# include <wx/utils.h>
# endif
2008-01-16 19:29:29 +01:00
2011-01-05 19:40:37 +01:00
# include "include/aegisub/menu.h"
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
# include "command/command.h"
# include "command/icon.h"
2011-01-05 19:40:37 +01:00
# include "include/aegisub/toolbar.h"
# include "include/aegisub/hotkey.h"
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
2009-09-10 15:06:40 +02:00
# include "ass_dialogue.h"
# include "ass_export_filter.h"
2006-01-16 22:02:54 +01:00
# include "ass_file.h"
2009-09-10 15:06:40 +02:00
# include "ass_time.h"
2006-01-16 22:02:54 +01:00
# include "audio_box.h"
2007-12-31 07:46:22 +01:00
# include "auto4_base.h"
2009-07-14 23:28:49 +02:00
# include "charset_conv.h"
2010-05-21 03:13:36 +02:00
# include "compat.h"
2011-01-21 07:09:04 +01:00
# include "export_clean_info.h"
# include "export_fixstyle.h"
2009-09-10 15:06:40 +02:00
# include "export_framerate.h"
# include "frame_main.h"
# include "main.h"
2010-05-21 03:13:36 +02:00
# include "libresrc/libresrc.h"
2009-09-10 15:06:40 +02:00
# include "plugin_manager.h"
# include "standard_paths.h"
# include "subtitle_format.h"
# include "version.h"
# include "video_context.h"
2006-01-16 22:02:54 +01:00
2010-05-21 03:13:36 +02:00
# include <libaegisub/io.h>
2010-05-21 05:52:11 +02:00
# include <libaegisub/access.h>
2010-06-01 10:21:30 +02:00
# include <libaegisub/log.h>
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
# include <libaegisub/hotkey.h>
2006-01-16 22:02:54 +01:00
2010-06-18 04:23:27 +02:00
namespace config {
agi : : Options * opt ;
agi : : MRUManager * mru ;
2011-02-08 06:05:54 +01:00
agi : : Path * path ;
2010-06-18 04:23:27 +02:00
}
2006-01-16 22:02:54 +01:00
///////////////////
// wxWidgets macro
IMPLEMENT_APP ( AegisubApp )
2011-09-28 21:43:11 +02:00
static const char * LastStartupState = NULL ;
2006-01-16 22:02:54 +01:00
2009-06-12 18:59:53 +02:00
# ifdef WITH_STARTUPLOG
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// DOCME
2011-09-28 21:43:11 +02:00
# define StartupLog(a) MessageBox(0, L ## a, L"Aegisub startup log", 0)
2007-07-05 21:11:54 +02:00
# else
2010-10-20 02:28:37 +02:00
# define StartupLog(a) LastStartupState = a
2007-07-05 21:11:54 +02:00
# endif
2008-03-09 22:00:55 +01:00
# ifdef __VISUALC__
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// DOCME
2008-03-09 22:00:55 +01:00
# define MS_VC_EXCEPTION 0x406d1388
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// DOCME
2008-03-09 22:00:55 +01:00
typedef struct tagTHREADNAME_INFO {
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// DOCME
2008-03-09 22:00:55 +01:00
DWORD dwType ; // must be 0x1000
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// DOCME
2008-03-09 22:00:55 +01:00
LPCSTR szName ; // pointer to name (in same addr space)
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// DOCME
2008-03-09 22:00:55 +01:00
DWORD dwThreadID ; // thread ID (-1 caller thread)
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// DOCME
2008-03-09 22:00:55 +01:00
DWORD dwFlags ; // reserved for future use, most be zero
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// DOCME
2008-03-09 22:00:55 +01:00
} THREADNAME_INFO ;
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief DOCME
/// @param dwThreadID
/// @param szThreadName
///
2008-03-09 22:00:55 +01:00
void SetThreadName ( DWORD dwThreadID , LPCSTR szThreadName ) {
THREADNAME_INFO info ;
info . dwType = 0x1000 ;
info . szName = szThreadName ;
info . dwThreadID = dwThreadID ;
info . dwFlags = 0 ;
__try {
2008-09-10 16:45:46 +02:00
RaiseException ( MS_VC_EXCEPTION , 0 , sizeof ( info ) / sizeof ( DWORD ) , ( ULONG_PTR * ) & info ) ;
2008-03-09 22:00:55 +01:00
}
__except ( EXCEPTION_CONTINUE_EXECUTION ) { }
}
# endif
2007-07-05 21:11:54 +02:00
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
2010-09-15 00:05:19 +02:00
/// @brief Handle wx assertions and redirct to the logging system.
/// @param file File name
/// @param line Line number
/// @param func Function name
/// @param cond Condition
/// @param msg Message
static void wxAssertHandler ( const wxString & file , int line , const wxString & func , const wxString & cond , const wxString & msg ) {
LOG_A ( " wx/assert " ) < < file < < " : " < < line < < " : " < < func < < " () " < < cond < < " : " < < msg ;
}
/// @brief Gets called when application starts.
/// @return bool
2006-01-16 22:02:54 +01:00
bool AegisubApp : : OnInit ( ) {
2011-01-16 08:15:18 +01:00
// App name (yeah, this is a little weird to get rid of an odd warning)
# if defined(__WXMSW__) || defined(__WXMAC__)
2011-09-28 21:43:11 +02:00
SetAppName ( " Aegisub " ) ;
2011-01-16 08:15:18 +01:00
# else
2011-09-28 21:43:11 +02:00
SetAppName ( " aegisub " ) ;
2011-01-16 08:15:18 +01:00
# endif
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
// logging.
2011-09-28 21:43:11 +02:00
const std : : string path_log ( StandardPaths : : DecodePath ( " ?user/log/ " ) ) ;
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
wxFileName : : Mkdir ( path_log , 0777 , wxPATH_MKDIR_FULL ) ;
agi : : log : : log = new agi : : log : : LogSink ( path_log ) ;
2010-06-18 04:23:27 +02:00
# ifdef _DEBUG
2010-07-25 19:33:44 +02:00
emit_stdout = new agi : : log : : EmitSTDOUT ( ) ;
emit_stdout - > Enable ( ) ;
2010-06-18 04:23:27 +02:00
# endif
2011-02-08 06:05:54 +01:00
std : : string path ( agi : : Path : : Config ( ) ) ;
config : : path = new agi : : Path ( path . append ( " path.json " ) , GET_DEFAULT_CONFIG ( default_path ) ) ;
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
// Init commands.
2011-07-15 06:05:01 +02:00
cmd : : init_builtin_commands ( ) ;
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
2011-10-28 22:40:32 +02:00
// Init hotkeys
hotkey : : init ( ) ;
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
// Init icons.
icon : : icon_init ( ) ;
2010-09-15 00:05:19 +02:00
// Install assertion handler
2010-09-15 07:19:01 +02:00
// wxSetAssertHandler(wxAssertHandler);
2010-09-15 00:05:19 +02:00
2011-09-28 21:43:11 +02:00
const std : : string conf_mru ( StandardPaths : : DecodePath ( " ?user/mru.json " ) ) ;
2010-06-18 04:23:27 +02:00
config : : mru = new agi : : MRUManager ( conf_mru , GET_DEFAULT_CONFIG ( default_mru ) ) ;
// Set config file
2011-09-28 21:43:11 +02:00
StartupLog ( " Load configuration " ) ;
2010-06-18 04:23:27 +02:00
try {
2011-09-28 21:43:11 +02:00
const std : : string conf_user ( StandardPaths : : DecodePath ( " ?user/config.json " ) ) ;
2010-06-18 04:23:27 +02:00
config : : opt = new agi : : Options ( conf_user , GET_DEFAULT_CONFIG ( default_config ) ) ;
} catch ( agi : : Exception & e ) {
2011-01-02 03:33:24 +01:00
LOG_E ( " config/init " ) < < " Caught exception: " < < e . GetName ( ) < < " -> " < < e . GetMessage ( ) ;
2010-06-18 04:23:27 +02:00
}
# ifdef __WXMSW__
// Try loading configuration from the install dir if one exists there
try {
2011-09-28 21:43:11 +02:00
const std : : string conf_local ( StandardPaths : : DecodePath ( " ?data/config.json " ) ) ;
2010-06-18 04:23:27 +02:00
std : : ifstream * localConfig = agi : : io : : Open ( conf_local ) ;
2010-06-18 09:23:17 +02:00
config : : opt - > ConfigNext ( * localConfig ) ;
2010-06-18 04:23:27 +02:00
delete localConfig ;
if ( OPT_GET ( " App/Local Config " ) - > GetBool ( ) ) {
// Local config, make ?user mean ?data so all user settings are placed in install dir
2011-09-28 21:43:11 +02:00
StandardPaths : : SetPathValue ( " ?user " , StandardPaths : : DecodePath ( " ?data " ) ) ;
2010-06-18 04:23:27 +02:00
}
} catch ( agi : : acs : : AcsError const & ) {
// File doesn't exist or we can't read it
// Might be worth displaying an error in the second case
}
# endif
2010-08-25 21:31:11 +02:00
try {
config : : opt - > ConfigUser ( ) ;
}
catch ( agi : : Exception const & err ) {
2011-09-28 21:43:11 +02:00
wxMessageBox ( " Configuration file is invalid. Error reported: \n " + lagi_wxString ( err . GetMessage ( ) ) , " Error " ) ;
2010-08-25 21:31:11 +02:00
}
2010-06-18 04:23:27 +02:00
2010-06-01 10:21:30 +02:00
2008-03-09 22:00:55 +01:00
# ifdef __VISUALC__
2008-03-13 20:12:55 +01:00
SetThreadName ( ( DWORD ) - 1 , " AegiMain " ) ;
2008-03-09 22:00:55 +01:00
# endif
2011-09-28 21:43:11 +02:00
StartupLog ( " Inside OnInit " ) ;
2008-03-07 00:41:27 +01:00
frame = NULL ;
2006-01-16 22:02:54 +01:00
try {
// Initialize randomizer
2011-09-28 21:43:11 +02:00
StartupLog ( " Initialize random generator " ) ;
2006-01-16 22:02:54 +01:00
srand ( time ( NULL ) ) ;
2007-04-03 06:34:56 +02:00
// locale for loading options
2011-09-28 21:43:11 +02:00
StartupLog ( " Set initial locale " ) ;
2007-04-03 06:34:56 +02:00
setlocale ( LC_NUMERIC , " C " ) ;
setlocale ( LC_CTYPE , " C " ) ;
2007-06-22 05:14:25 +02:00
// Crash handling
2009-09-02 09:59:17 +02:00
# if !defined(_DEBUG) || defined(WITH_EXCEPTIONS)
2011-09-28 21:43:11 +02:00
StartupLog ( " Install exception handler " ) ;
2006-01-16 22:02:54 +01:00
wxHandleFatalExceptions ( true ) ;
2007-07-01 02:19:55 +02:00
# endif
2006-01-16 22:02:54 +01:00
2011-09-28 21:43:11 +02:00
StartupLog ( " Store options back " ) ;
2010-05-21 03:13:36 +02:00
OPT_SET ( " Version/Last Version " ) - > SetInt ( GetSVNRevision ( ) ) ;
AssTime : : UseMSPrecision = OPT_GET ( " App/Nonstandard Milisecond Times " ) - > GetBool ( ) ;
2006-01-16 22:02:54 +01:00
2011-09-28 21:43:11 +02:00
StartupLog ( " Initialize final locale " ) ;
2009-01-02 09:49:43 +01:00
2006-01-16 22:02:54 +01:00
// Set locale
2010-05-21 03:13:36 +02:00
int lang = OPT_GET ( " App/Locale " ) - > GetInt ( ) ;
2006-01-16 22:02:54 +01:00
if ( lang = = - 1 ) {
lang = locale . PickLanguage ( ) ;
2010-05-21 03:13:36 +02:00
OPT_SET ( " App/Locale " ) - > SetInt ( lang ) ;
2006-01-16 22:02:54 +01:00
}
locale . Init ( lang ) ;
2008-03-07 01:47:57 +01:00
// Load plugins
plugins = new PluginManager ( ) ;
plugins - > RegisterBuiltInPlugins ( ) ;
2007-04-22 17:45:29 +02:00
2006-12-28 23:31:33 +01:00
// Load Automation scripts
2011-09-28 21:43:11 +02:00
StartupLog ( " Load global Automation scripts " ) ;
2010-05-21 03:13:36 +02:00
global_scripts = new Automation4 : : AutoloadScriptManager ( lagi_wxString ( OPT_GET ( " Path/Automation/Autoload " ) - > GetString ( ) ) ) ;
2006-12-28 23:31:33 +01:00
2006-01-16 22:02:54 +01:00
// Load export filters
2011-09-28 21:43:11 +02:00
StartupLog ( " Register export filters " ) ;
2011-01-21 07:09:04 +01:00
AssExportFilterChain : : Register ( new AssFixStylesFilter ) ;
AssExportFilterChain : : Register ( new AssTransformCleanInfoFilter ) ;
AssExportFilterChain : : Register ( new AssTransformFramerateFilter ) ;
2006-01-16 22:02:54 +01:00
// Get parameter subs
2011-09-28 21:43:11 +02:00
StartupLog ( " Parse command line " ) ;
2006-01-16 22:02:54 +01:00
wxArrayString subs ;
for ( int i = 1 ; i < argc ; i + + ) {
subs . Add ( argv [ i ] ) ;
}
// Open main frame
2011-09-28 21:43:11 +02:00
StartupLog ( " Create main window " ) ;
2006-01-16 22:02:54 +01:00
frame = new FrameMain ( subs ) ;
SetTopWindow ( frame ) ;
}
2011-09-28 21:43:11 +02:00
catch ( const char * err ) {
wxMessageBox ( err , " Fatal error while initializing " ) ;
2006-01-16 22:02:54 +01:00
return false ;
}
2010-06-03 22:32:25 +02:00
catch ( agi : : Exception const & e ) {
2011-09-28 21:43:11 +02:00
wxMessageBox ( e . GetMessage ( ) , " Fatal error while initializing " ) ;
2010-06-03 22:32:25 +02:00
return false ;
}
2006-01-16 22:02:54 +01:00
2011-08-27 08:29:36 +02:00
# ifndef _DEBUG
2006-01-16 22:02:54 +01:00
catch ( . . . ) {
2011-09-28 21:43:11 +02:00
wxMessageBox ( " Unhandled exception " , " Fatal error while initializing " ) ;
2006-01-16 22:02:54 +01:00
return false ;
}
2011-08-27 08:29:36 +02:00
# endif
2006-01-16 22:02:54 +01:00
2011-09-28 21:43:11 +02:00
StartupLog ( " Initialization complete " ) ;
2006-01-16 22:02:54 +01:00
return true ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Exit
/// @return
///
2007-01-15 06:38:32 +01:00
int AegisubApp : : OnExit ( ) {
2007-01-15 07:56:35 +01:00
SubtitleFormat : : DestroyFormats ( ) ;
2010-08-27 03:01:35 +02:00
VideoContext : : OnExit ( ) ;
2008-03-07 01:47:57 +01:00
delete plugins ;
2010-06-18 04:23:27 +02:00
delete config : : opt ;
delete config : : mru ;
2011-10-28 22:40:32 +02:00
hotkey : : clear ( ) ;
2011-02-08 06:05:54 +01:00
delete config : : path ;
2011-07-15 19:36:17 +02:00
cmd : : clear ( ) ;
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
2007-01-15 07:56:35 +01:00
delete global_scripts ;
2011-07-15 19:36:26 +02:00
AssExportFilterChain : : Clear ( ) ;
2010-07-25 19:33:44 +02:00
# ifdef _DEBUG
delete emit_stdout ;
2007-12-31 07:46:22 +01:00
# endif
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
// Keep this last!
delete agi : : log : : log ;
2007-01-15 06:38:32 +01:00
return wxApp : : OnExit ( ) ;
}
2009-09-02 09:59:17 +02:00
# if !defined(_DEBUG) || defined(WITH_EXCEPTIONS)
2009-09-02 22:46:15 +02:00
/// Message displayed when an exception has occurred.
const static wxString exception_message = _ ( " Oops, Aegisub has crashed! \n \n An attempt has been made to save a copy of your file to: \n \n %s \n \n Aegisub will now close. " ) ;
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
2010-10-20 02:28:37 +02:00
static void UnhandledExeception ( bool stackWalk ) {
if ( AssFile : : top ) {
// Current filename if any.
wxFileName file ( AssFile : : top - > filename ) ;
2011-09-28 21:43:11 +02:00
if ( ! file . HasName ( ) ) file . SetName ( " untitled " ) ;
2010-10-20 02:28:37 +02:00
// Set path and create if it doesn't exist.
2011-09-28 21:43:11 +02:00
file . SetPath ( StandardPaths : : DecodePath ( " ?user/recovered " ) ) ;
2010-10-20 02:28:37 +02:00
if ( ! file . DirExists ( ) ) file . Mkdir ( ) ;
2009-09-03 07:27:11 +02:00
2010-10-20 02:28:37 +02:00
// Save file
wxString filename = wxString : : Format ( " %s/%s_%s.ass " , file . GetPath ( ) , wxDateTime : : Now ( ) . Format ( " %Y-%m-%d-%H%M%S " ) , file . GetName ( ) ) ;
AssFile : : top - > Save ( filename , false , false ) ;
2009-09-03 07:27:11 +02:00
2010-10-20 02:28:37 +02:00
# if wxUSE_STACKWALKER == 1
if ( stackWalk ) {
2011-09-28 21:43:11 +02:00
StackWalker walker ( " Fatal exception " ) ;
2010-10-20 02:28:37 +02:00
walker . WalkFromException ( ) ;
}
# endif
2006-02-21 06:26:13 +01:00
2010-10-20 02:28:37 +02:00
// Inform user of crash.
2011-09-28 21:43:48 +02:00
wxMessageBox ( wxString : : Format ( exception_message , filename ) , _ ( " Program error " ) , wxOK | wxICON_ERROR , NULL ) ;
2010-10-20 02:28:37 +02:00
}
else if ( LastStartupState ) {
# if wxUSE_STACKWALKER == 1
if ( stackWalk ) {
2011-09-28 21:43:11 +02:00
StackWalker walker ( " Fatal exception " ) ;
2010-10-20 02:28:37 +02:00
walker . WalkFromException ( ) ;
}
# endif
wxMessageBox ( wxString : : Format ( " Aegisub has crashed while starting up! \n \n The last startup step attempted was: %s. " , LastStartupState ) , _ ( " Program error " ) , wxOK | wxICON_ERROR ) ;
}
}
/// @brief Called during an unhandled exception
void AegisubApp : : OnUnhandledException ( ) {
UnhandledExeception ( false ) ;
2006-01-16 22:02:54 +01:00
}
2009-09-09 09:04:10 +02:00
2009-09-03 07:27:11 +02:00
/// @brief Called during a fatal exception.
void AegisubApp : : OnFatalException ( ) {
2010-10-20 02:28:37 +02:00
UnhandledExeception ( true ) ;
2006-02-21 06:26:13 +01:00
}
2006-02-26 23:45:34 +01:00
# endif
2006-02-21 06:26:13 +01:00
2010-06-29 12:31:15 +02:00
void AegisubApp : : HandleEvent ( wxEvtHandler * handler , wxEventFunction func , wxEvent & event ) const {
2011-09-28 21:43:11 +02:00
# define SHOW_EXCEPTION(str) wxMessageBox(str, "Exception in event handler", wxOK|wxICON_ERROR|wxSTAY_ON_TOP)
2010-06-29 12:31:15 +02:00
try {
wxApp : : HandleEvent ( handler , func , event ) ;
}
catch ( const agi : : Exception & e ) {
SHOW_EXCEPTION ( lagi_wxString ( e . GetChainedMessage ( ) ) ) ;
}
catch ( const std : : exception & e ) {
SHOW_EXCEPTION ( wxString ( e . what ( ) , wxConvUTF8 ) ) ;
}
catch ( const char * e ) {
SHOW_EXCEPTION ( wxString ( e , wxConvUTF8 ) ) ;
}
catch ( const wxString & e ) {
SHOW_EXCEPTION ( e ) ;
}
# undef SHOW_EXCEPTION
}
2009-09-03 08:03:38 +02:00
# if wxUSE_STACKWALKER == 1
2009-09-09 09:04:10 +02:00
/// @brief Called at the start of walking the stack.
/// @param cause cause of the crash.
///
StackWalker : : StackWalker ( wxString cause ) {
wxFileName report_dir ( " " ) ;
2011-09-28 21:43:11 +02:00
report_dir . SetPath ( StandardPaths : : DecodePath ( " ?user/reporter " ) ) ;
2009-09-09 09:04:10 +02:00
if ( ! report_dir . DirExists ( ) ) report_dir . Mkdir ( ) ;
crash_text = new wxFile ( StandardPaths : : DecodePath ( " ?user/crashlog.txt " ) , wxFile : : write_append ) ;
crash_xml = new wxFile ( StandardPaths : : DecodePath ( " ?user/reporter/crash.xml " ) , wxFile : : write ) ;
if ( ( crash_text - > IsOpened ( ) ) & & ( crash_xml - > IsOpened ( ) ) ) {
wxDateTime time = wxDateTime : : Now ( ) ;
crash_text - > Write ( wxString : : Format ( " --- %s ------------------ \n " , time . FormatISOCombined ( ) ) ) ;
crash_text - > Write ( wxString : : Format ( " VER - %s \n " , GetAegisubLongVersionString ( ) ) ) ;
crash_text - > Write ( wxString : : Format ( " FTL - Begining stack dump for \" %s \" : \n " , cause ) ) ;
crash_xml - > Write ( " <crash> \n " ) ;
crash_xml - > Write ( " <info> \n " ) ;
crash_xml - > Write ( wxString : : Format ( " <cause>%s</cause> \n " , cause ) ) ;
crash_xml - > Write ( wxString : : Format ( " <time>%s</time> \n " , time . FormatISOCombined ( ) ) ) ;
crash_xml - > Write ( wxString : : Format ( " <version>%s</version> \n " , GetAegisubLongVersionString ( ) ) ) ;
crash_xml - > Write ( " </info> \n " ) ;
crash_xml - > Write ( " <trace> \n " ) ;
}
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
2009-09-03 07:27:11 +02:00
/// @brief Callback to format a single frame
/// @param frame frame to parse.
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
///
2006-02-21 06:26:13 +01:00
void StackWalker : : OnStackFrame ( const wxStackFrame & frame ) {
2009-09-09 09:04:10 +02:00
if ( ( crash_text - > IsOpened ( ) ) & & ( crash_xml - > IsOpened ( ) ) ) {
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
2009-09-09 09:04:10 +02:00
wxString dst = wxString : : Format ( " %03i - 0x%08X: " , frame . GetLevel ( ) , frame . GetAddress ( ) ) + frame . GetName ( ) ;
if ( frame . HasSourceLocation ( ) )
dst = wxString : : Format ( " %s on %s:%d " , dst , frame . GetFileName ( ) , frame . GetLine ( ) ) ;
crash_text - > Write ( wxString : : Format ( " %s \n " , dst ) ) ;
crash_xml - > Write ( wxString : : Format ( " <frame id='%i' loc='%X'> \n " , frame . GetLevel ( ) , frame . GetAddress ( ) ) ) ;
crash_xml - > Write ( wxString : : Format ( " <name>%s</name> \n " , frame . GetName ( ) ) ) ;
if ( frame . HasSourceLocation ( ) )
crash_xml - > Write ( wxString : : Format ( " <file line='%d'>%s</file>>%s</name> \n " , frame . GetLine ( ) , frame . GetFileName ( ) ) ) ;
crash_xml - > Write ( wxString : : Format ( " <module><![CDATA[%s]]></module> \n " , frame . GetModule ( ) ) ) ;
crash_xml - > Write ( " </frame> \n " ) ;
2006-02-21 06:26:13 +01:00
}
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
2009-09-03 07:27:11 +02:00
/// @brief Called at the end of walking the stack.
2006-02-21 06:26:13 +01:00
StackWalker : : ~ StackWalker ( ) {
2009-09-09 09:04:10 +02:00
if ( ( crash_text - > IsOpened ( ) ) & & ( crash_xml - > IsOpened ( ) ) ) {
crash_text - > Write ( " End of stack dump. \n " ) ;
crash_text - > Write ( " ---------------------------------------- \n \n " ) ;
crash_text - > Close ( ) ;
crash_xml - > Write ( " </trace> \n " ) ;
crash_xml - > Write ( " </crash> \n " ) ;
crash_xml - > Close ( ) ;
2006-02-21 06:26:13 +01:00
}
2006-01-16 22:02:54 +01:00
}
2006-04-13 09:09:27 +02:00
# endif
2006-01-16 22:02:54 +01:00
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Call main loop
/// @return
///
2006-01-16 22:02:54 +01:00
int AegisubApp : : OnRun ( ) {
2008-03-10 07:28:21 +01:00
wxString error ;
// Run program
2006-01-16 22:02:54 +01:00
try {
if ( m_exitOnFrameDelete = = Later ) m_exitOnFrameDelete = Yes ;
return MainLoop ( ) ;
}
2008-03-10 07:28:21 +01:00
// Catch errors
2010-10-20 02:28:37 +02:00
catch ( const wxString & err ) { error = err ; }
2011-09-28 21:43:11 +02:00
catch ( const char * err ) { error = err ; }
catch ( const std : : exception & e ) { error = wxString ( " std::exception: " ) + wxString ( e . what ( ) , wxConvUTF8 ) ; }
2010-10-20 02:28:37 +02:00
catch ( const agi : : Exception & e ) { error = " agi::exception: " + lagi_wxString ( e . GetChainedMessage ( ) ) ; }
2011-09-28 21:43:11 +02:00
catch ( . . . ) { error = " Program terminated in error. " ; }
2008-03-10 07:28:21 +01:00
// Report errors
if ( ! error . IsEmpty ( ) ) {
std : : ofstream file ;
2011-09-28 21:43:11 +02:00
file . open ( wxString ( StandardPaths : : DecodePath ( " ?user/crashlog.txt " ) ) . mb_str ( ) , std : : ios : : out | std : : ios : : app ) ;
2008-03-10 07:28:21 +01:00
if ( file . is_open ( ) ) {
wxDateTime time = wxDateTime : : Now ( ) ;
2011-09-28 21:43:11 +02:00
wxString timeStr = " --- " + time . FormatISODate ( ) + " " + time . FormatISOTime ( ) + " ------------------ " ;
2009-07-14 23:28:49 +02:00
file < < std : : endl < < timeStr . mb_str ( csConvLocal ) ;
2011-07-28 00:52:37 +02:00
file < < " \n VER - " < < GetAegisubLongVersionString ( ) ;
2009-07-14 23:28:49 +02:00
file < < " \n EXC - Aegisub has crashed with unhandled exception \" " < < error . mb_str ( csConvLocal ) < < " \" . \n " ;
2008-03-10 07:28:21 +01:00
int formatLen = timeStr . Length ( ) ;
char dashes [ 1024 ] ;
int i = 0 ;
for ( i = 0 ; i < formatLen ; i + + ) dashes [ i ] = ' - ' ;
dashes [ i ] = 0 ;
file < < dashes ;
file < < " \n " ;
file . close ( ) ;
}
2006-01-16 22:02:54 +01:00
2010-01-26 14:18:53 +01:00
# if wxUSE_EXCEPTIONS
2008-03-10 07:28:21 +01:00
OnUnhandledException ( ) ;
2010-01-26 14:18:53 +01:00
# endif
2006-01-16 22:02:54 +01:00
}
ExitMainLoop ( ) ;
return 1 ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Open URL
/// @param url
///
2007-01-07 23:54:04 +01:00
void AegisubApp : : OpenURL ( wxString url ) {
2007-04-13 02:04:44 +02:00
wxLaunchDefaultBrowser ( url , wxBROWSER_NEW_WINDOW ) ;
2007-01-07 23:54:04 +01:00
}
2006-06-19 04:57:27 +02:00
////////////////
// Apple events
# ifdef __WXMAC__
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief DOCME
/// @param filename
///
2006-06-19 04:57:27 +02:00
void AegisubApp : : MacOpenFile ( const wxString & filename ) {
if ( frame ! = NULL & & ! filename . empty ( ) ) {
frame - > LoadSubtitles ( filename ) ;
wxFileName filepath ( filename ) ;
2010-05-21 03:13:36 +02:00
OPT_SET ( " Path/Last/Subtitles " ) - > SetString ( STD_STR ( filepath . GetPath ( ) ) ) ;
2006-06-19 04:57:27 +02:00
}
}
# endif