Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2010-01-05 17:27:13 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2010-01-05 17:27:13 +0300
commita1034a0526aa81c5901ba924aec0bb74413edee7 (patch)
treece9c91e228eb60a277607f6222aefa39f5eaed94 /source/blender/editors/space_text
parentd16547ab73e7086d5358bba67093173827d12afe (diff)
Fix #20571: run script operator crashes in 3d view.
Diffstat (limited to 'source/blender/editors/space_text')
-rw-r--r--source/blender/editors/space_text/text_ops.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index 1a23b9ecc42..0504db51a72 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -526,6 +526,11 @@ void TEXT_OT_save_as(wmOperatorType *ot)
/******************* run script operator *********************/
+static int run_script_poll(bContext *C)
+{
+ return (CTX_data_edit_text(C) != NULL);
+}
+
static int run_script_exec(bContext *C, wmOperator *op)
{
#ifdef DISABLE_PYTHON
@@ -534,12 +539,13 @@ static int run_script_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
#else
Text *text= CTX_data_edit_text(C);
+ SpaceText *st= CTX_wm_space_text(C);
if (BPY_run_python_script(C, NULL, text, op->reports))
return OPERATOR_FINISHED;
/* Dont report error messages while live editing */
- if(!CTX_wm_space_text(C)->live_edit)
+ if(!(st && st->live_edit))
BKE_report(op->reports, RPT_ERROR, "Python script fail, look in the console for now...");
return OPERATOR_CANCELLED;
@@ -554,8 +560,8 @@ void TEXT_OT_run_script(wmOperatorType *ot)
ot->description= "Run active script.";
/* api callbacks */
+ ot->poll= run_script_poll;
ot->exec= run_script_exec;
-// ot->poll= text_edit_poll; // dont do this since linked texts cant run
}