Page 1 of 1

[CELayoutEditor] - Exception handling, logs, bugfixes, etc.

Posted: Fri Oct 19, 2007 17:08
by fjeronimo
Hi people,

I committed a new update to CELayoutEditor.

These are mostly internal changes that do not reflect into visible changes in the application features. However, they greatly increase ease of development for future updates and most importantly, the program should NEVER crash without informing the user and logging the problem not even when a fatal exception occurs such as an unhandled win32 segmentation fault, thus facilitating the debug process.

---------------//-----------------

Update features:

- New: Exception handling - More robust exception handling mechanism provided by overridding the wxApp::OnUnhandledException() and wxApp::HandleEvent() functions. This allows the application to catch, log and inform the user of all thrown unhandled C++ exceptions.

NOTE: wxWidgets must be built with wxUSE_EXCEPTIONS = 1 (default).

- New: Fatal Errors - Fatal errors (such as an unhandled win32 exception or a fatal signal under Unix) are also caught by overriding wxApp::OnFatalException(). A debug report (with the current system state, stack trace, log file and configuration file) is now generated at the user's convenience.

- New: Helper Exception Macros - Created helper macros LOG_EXCEPTION, LOG_EXCEPTION_RETURN, SHOW_EXCEPTION and SHOW_EXCEPTION_RETURN that catch and log CEGUI, standard and non-standard exceptions. The last two also inform the user of the exception (with a message box). The RETURN variant of each macro allows to supply a return value of any type if an exception is detected.

- New: Log Wrappers - Added wrappers around the wxLog* family of functions that besides processing the default wxWidgets behavior for the message type also save the message to log (CEGUI.log).


NOTE: Be sure that the arguments supplied are wxStrings or wxChar* and not other string types (like CEGUI::String or char*) because it could lead to unpredictable results and Win32 'Access Violation' exceptions that will crash the application (activating CELayoutEditor::OnFatalException() method). See BugFix below for more info.

- New: StringHelper Placebos - Added placebo functions to ToWXString() and ToCEGUIString() that allow to pass the string in the already correct format and return it untouched. This is useful to ensure that the call always works even when we don't know beforehand the type of string that will be processed (for instance in macros like LOG_EXCEPTION).

- New: Terminate on unhandled - Added #define TERMINATE_ON_UNHANDLED which specifies if the application is to exit when an unhandled exception is found (1) or not (0).

- New: Show unhandled - Added #define SHOW_UNHANDLED which specifies if an unhandled exception is to be logged and shown to the user (1) or only logged (0).

- New: Prevent save on unhandled - Added #define PREVENT_SAVE_ON_UNHANDLED which specifies if the user is allowed to save the file after an unhandled exception (0) or not (1). Only relevant if TERMINATE_ON_UNHANDLED is set to 1.

- New: Use modal message boxes - Added #define USE_MODAL_MESSAGE_BOXES which specifies if message boxes (info, error, warning) are displayed in modal (1) or modeless mode (0).


- Change (Debug) : Skin changer exception handling - Added exception handling when changing a widget skin. The user is informed of what went wrong.

- Change (Minor): Tag removal - Removed all FJDS tags (mine) that were starting to pollute the code.

- Change: Code cleaning - Reformatted and commented some of the existing code.


- BugFix: Fatal Log Exceptions - Fixed several locations where CEGUI strings were being passed directly to wxWidgets log functions, thus creating an unstable system processing that could lead to fatal errors, like Win32 'Access Violation' exceptions. Log functions are now being supplied only with wxStrings or wxChar* parameters with conversions being assured by the StringHelper::ToWXString() function.

- BugFix : Lock/Unlock tooltip text - The (un)lock icons tooltip now display the correct text.


Edit (21/10/07):
- BugFix: Missing ini crash - Fixed two situations where a crash would occur if the CELayoutEditor ini file didn't exist (i.e. first time CELayoutEditor is run).

I hope you like this.

Best regards,

Posted: Sun Oct 21, 2007 16:23
by fjeronimo
Added a quick update that prevents two crash situations.