diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-09-23 10:25:39 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-09-23 10:25:39 +0400 |
commit | 552cd4b7e71fb30843059f356445b32e954c2df9 (patch) | |
tree | 6d4a6a5a0bd7996e0534021a55bd856011fbb838 /source/blender/editors/space_text/text_ops.c | |
parent | 3e9a09d385b1e070b9bf30864c0f5d974f80b80a (diff) |
fix for crash executing a python script.
nice obscure case, when a script executes, frees its self (by loading a file for eg), then has a python error.
... in this case blender would fetch the python exception and attempt to move the cursor in the freed textblock to the error line, crashing blender.
Diffstat (limited to 'source/blender/editors/space_text/text_ops.c')
-rw-r--r-- | source/blender/editors/space_text/text_ops.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 2dd6599cecf..75b8e2f218d 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -602,9 +602,12 @@ static int text_run_script(bContext *C, ReportList *reports) /* Don't report error messages while live editing */ if (!is_live) { - if (text->curl != curl_prev || curc_prev != text->curc) { - text_update_cursor_moved(C); - WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text); + /* text may have freed its self */ + if (CTX_data_edit_text(C) == text) { + if (text->curl != curl_prev || curc_prev != text->curc) { + text_update_cursor_moved(C); + WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text); + } } BKE_report(reports, RPT_ERROR, "Python script fail, look in the console for now..."); |