[DEVELOPMENT ENVIRONMENT]

* NEW: If the IDE throws an uncatched error, try to save all modified files
  before aborting.

[INTERPRETER]
* NEW: If a static public method named Application_Error() is defined in 
  the startup class, then this method will be called when an unhandled 
  error is thrown, just before the program is aborted.


git-svn-id: svn://localhost/gambas/trunk@5678 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2013-05-25 14:00:40 +00:00
parent 47d9021e13
commit daaf410362
6 changed files with 133 additions and 92 deletions

View File

@ -10,6 +10,14 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: .project:1
msgid "Gambas 3"
msgstr ""
#: .project:2
msgid "Integrated Development Environment for Gambas"
msgstr ""
#: CBookmark.class:33
msgid "Define bookmark"
msgstr ""
@ -477,48 +485,6 @@ msgstr ""
msgid "Gambas reports"
msgstr ""
#: ComponentItem.class:139 FProjectProperty.class:1253
#: FPropertyComponent.form:80
msgid "Experimental"
msgstr ""
#: ComponentItem.class:141 FProjectProperty.class:1251
#: FPropertyComponent.form:80
msgid "Not finished but stable"
msgstr ""
#: ComponentItem.class:144 ProjectItem.class:82
msgid "Authors"
msgstr ""
#: ComponentItem.class:153
msgid "Excludes"
msgstr ""
#: ComponentItem.class:159
msgid "Implements"
msgstr ""
#: ComponentItem.class:240
msgid "This component is required by the following library:<p>&1"
msgstr ""
#: ComponentItem.class:242
msgid "This component is required by the following libraries:<p>&1"
msgstr ""
#: ComponentItem.class:251
msgid "This component is required by:<p>&1"
msgstr ""
#: ComponentItem.class:252
msgid "Keep"
msgstr ""
#: ComponentItem.class:252 FDebugInfo.form:157
msgid "Remove all"
msgstr ""
#: CProfile.class:111
msgid "Evaluator"
msgstr ""
@ -581,7 +547,7 @@ msgstr ""
#: FReportBrushChooser.form:34 FReportCoordChooser.form:26
#: FReportPaddingChooser.form:75 FSave.form:28 FSaveProjectAs.form:76
#: FSearch.class:869 FSelectExtraFile.form:43 FSelectIcon.form:87
#: FSnippet.form:57 FTableChooser.form:68 FTextEditor.class:599 FText.form:41
#: FSnippet.form:57 FTableChooser.form:68 FText.form:41 FTextEditor.class:599
#: FTranslate.class:552 Project.module:469
msgid "Cancel"
msgstr ""
@ -594,6 +560,48 @@ msgstr ""
msgid "The Gambas font is published under the SIL Open Font License."
msgstr ""
#: ComponentItem.class:139 FProjectProperty.class:1253
#: FPropertyComponent.form:80
msgid "Experimental"
msgstr ""
#: ComponentItem.class:141 FProjectProperty.class:1251
#: FPropertyComponent.form:80
msgid "Not finished but stable"
msgstr ""
#: ComponentItem.class:144 ProjectItem.class:82
msgid "Authors"
msgstr ""
#: ComponentItem.class:153
msgid "Excludes"
msgstr ""
#: ComponentItem.class:159
msgid "Implements"
msgstr ""
#: ComponentItem.class:240
msgid "This component is required by the following library:<p>&1"
msgstr ""
#: ComponentItem.class:242
msgid "This component is required by the following libraries:<p>&1"
msgstr ""
#: ComponentItem.class:251
msgid "This component is required by:<p>&1"
msgstr ""
#: ComponentItem.class:252
msgid "Keep"
msgstr ""
#: ComponentItem.class:252 FDebugInfo.form:157
msgid "Remove all"
msgstr ""
#: Design.module:159 Project.module:2107
msgid "first"
msgstr ""
@ -4080,38 +4088,6 @@ msgstr ""
msgid "Author"
msgstr ""
#: FPropertyComponent.form:73
msgid "Component advancement"
msgstr ""
#: FPropertyComponent.form:80
msgid "Finished and stable"
msgstr ""
#: FPropertyComponent.form:91
msgid "This component is hidden"
msgstr ""
#: FPropertyComponent.form:108
msgid "Compatible until version"
msgstr ""
#: FPropertyComponent.form:133
msgid "Exported classes"
msgstr ""
#: FPropertyComponent.form:147
msgid "Features"
msgstr ""
#: FPropertyComponent.form:242
msgid "Remove All"
msgstr ""
#: FPropertyComponent.class:154
msgid "Cannot write component description file."
msgstr ""
#: FProperty.form:47
msgid "Lock property"
msgstr ""
@ -4163,6 +4139,38 @@ msgstr ""
msgid "Select a file"
msgstr ""
#: FPropertyComponent.form:73
msgid "Component advancement"
msgstr ""
#: FPropertyComponent.form:80
msgid "Finished and stable"
msgstr ""
#: FPropertyComponent.form:91
msgid "This component is hidden"
msgstr ""
#: FPropertyComponent.form:108
msgid "Compatible until version"
msgstr ""
#: FPropertyComponent.form:133
msgid "Exported classes"
msgstr ""
#: FPropertyComponent.form:147
msgid "Features"
msgstr ""
#: FPropertyComponent.form:242
msgid "Remove All"
msgstr ""
#: FPropertyComponent.class:154
msgid "Cannot write component description file."
msgstr ""
#: FProxy.form:20
msgid "Proxy configuration"
msgstr ""
@ -4423,6 +4431,14 @@ msgstr ""
msgid "Choose a table"
msgstr ""
#: FText.form:12
msgid "Edit text property"
msgstr ""
#: FText.form:30
msgid "Use a fixed font"
msgstr ""
#: FTextEditor.form:188
msgid "Compress file"
msgstr ""
@ -4443,14 +4459,6 @@ msgstr ""
msgid "Unable to compress file."
msgstr ""
#: FText.form:12
msgid "Edit text property"
msgstr ""
#: FText.form:30
msgid "Use a fixed font"
msgstr ""
#: FTips.form:18
msgid "Tips of the day"
msgstr ""
@ -6063,14 +6071,6 @@ msgstr ""
msgid "Patch didn't apply:\n"
msgstr ""
#: .project:1
msgid "Gambas 3"
msgstr ""
#: .project:2
msgid "Integrated Development Environment for Gambas"
msgstr ""
#: Project.module:193
msgid "Automation"
msgstr ""

View File

@ -5425,3 +5425,11 @@ Public Sub SetBackground(sBackground As String)
FMain.OnBackgroundChange
End
' Try to save all files if there is an unexpected error
Public Sub Application_Error()
Try Save
End

View File

@ -32,6 +32,7 @@
#include "gbx_exec.h"
#include "gbx_api.h"
#include "gbx_stack.h"
#include "gbx_project.h"
#include "gb_error.h"
//#define DEBUG_ERROR 1
@ -692,3 +693,28 @@ void ERROR_exit(void)
STACK_free_backtrace(&ERROR_backtrace);
}
void ERROR_hook(void)
{
ERROR_INFO save = { 0 };
ERROR_INFO last = { 0 };
CLASS_DESC_METHOD *handle_error = (CLASS_DESC_METHOD *)CLASS_get_symbol_desc_kind(PROJECT_class, "Application_Error", CD_STATIC_METHOD, 0);
if (handle_error)
{
ERROR_save(&save, &last);
TRY
{
ERROR_restore(&save, &last);
EXEC_public_desc(PROJECT_class, NULL, handle_error, 0);
}
CATCH
{
ERROR_save(&save, &last);
}
END_TRY
ERROR_restore(&save, &last);
}
}

View File

@ -166,6 +166,7 @@ void ERROR_warning(const char *warning, ...);
void ERROR_print(void);
void ERROR_print_at(FILE *where, bool msgonly, bool newline);
void ERROR_hook(void);
void ERROR_save(ERROR_INFO *save, ERROR_INFO *last);
void ERROR_restore(ERROR_INFO *save, ERROR_INFO *last);

View File

@ -171,6 +171,7 @@ static bool is_option_arg(char **argv, int argc, int *i, char option, const char
return FALSE;
}
static bool is_long_option(const char *arg, char option, char *long_option)
{
if (is_option(arg, option))
@ -179,9 +180,9 @@ static bool is_long_option(const char *arg, char option, char *long_option)
return (arg[0] == '-' && arg[1] == '-' && !strcmp(&arg[2], long_option));
}
int main(int argc, char *argv[])
{
//CLASS *class = NULL;
CLASS_DESC_METHOD *startup = NULL;
int i, n;
char *file = NULL;
@ -366,6 +367,8 @@ int main(int argc, char *argv[])
}
CATCH
{
ERROR_hook();
if (EXEC_debug)
{
if (!_welcome)
@ -413,6 +416,8 @@ int main(int argc, char *argv[])
{
if (ERROR->info.code && ERROR->info.code != E_ABORT)
{
ERROR_hook();
if (EXEC_debug)
{
DEBUG.Main(TRUE);

View File

@ -981,6 +981,7 @@ void EXEC_function_loop()
if (EXEC_debug && !STACK_has_error_handler())
{
ERROR_hook();
DEBUG.Main(TRUE);
if (TP && TC)