fix for crash with textbox add poll function, missing NULL check.
authorCampbell Barton <ideasman42@gmail.com>
Tue, 15 Mar 2011 08:38:08 +0000 (08:38 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 15 Mar 2011 08:38:08 +0000 (08:38 +0000)
source/blender/editors/curve/editfont.c
source/blender/editors/include/ED_screen.h
source/blender/editors/screen/screen_ops.c

index 798a9d0f7cd49917e40162762fde050c2c97c0c5..2f6bd0abcef49e8f7024962ce92a687bcb415802 100644 (file)
@@ -1373,16 +1373,6 @@ void FONT_OT_text_insert(wmOperatorType *ot)
 
 
 /*********************** textbox add operator *************************/
-static int textbox_poll(bContext *C)
-{
-       Object *ob = CTX_data_active_object(C);
-       
-       if (!ED_operator_object_active_editable(C) ) return 0;
-       if (ob->type != OB_FONT) return 0;
-       
-       return 1;
-}
-
 static int textbox_add_exec(bContext *C, wmOperator *UNUSED(op))
 {
        Object *obedit= CTX_data_active_object(C);
@@ -1409,8 +1399,8 @@ void FONT_OT_textbox_add(wmOperatorType *ot)
        
        /* api callbacks */
        ot->exec= textbox_add_exec;
-       ot->poll= textbox_poll;
-       
+       ot->poll= ED_operator_object_active_editable_font;
+
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
        
@@ -1452,7 +1442,7 @@ void FONT_OT_textbox_remove(wmOperatorType *ot)
        
        /* api callbacks */
        ot->exec= textbox_remove_exec;
-       ot->poll= textbox_poll;
+       ot->poll= ED_operator_object_active_editable_font;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
index 71c732d664772f67795c88d95b6b6f95e5740e9b..93ce82fa48360234d6248eca928f0a1880575163 100644 (file)
@@ -154,6 +154,7 @@ int         ED_operator_console_active(struct bContext *C);
 int            ED_operator_object_active(struct bContext *C);
 int            ED_operator_object_active_editable(struct bContext *C);
 int            ED_operator_object_active_editable_mesh(struct bContext *C);
+int            ED_operator_object_active_editable_font(struct bContext *C);
 int            ED_operator_editmesh(struct bContext *C);
 int            ED_operator_editmesh_view3d(struct bContext *C);
 int            ED_operator_editmesh_region_view3d(struct bContext *C);
index 0c3a430089ff2ad23dac7146215853b0b086e4c5..72cc4a48105518625d706f1524ee1e719e03a7f8 100644 (file)
@@ -282,6 +282,12 @@ int ED_operator_object_active_editable_mesh(bContext *C)
        return ((ob != NULL) && !(ob->id.lib) && !(ob->restrictflag & OB_RESTRICT_VIEW) && ob->type == OB_MESH);
 }
 
+int ED_operator_object_active_editable_font(bContext *C)
+{
+       Object *ob = ED_object_active_context(C);
+       return ((ob != NULL) && !(ob->id.lib) && !(ob->restrictflag & OB_RESTRICT_VIEW) && ob->type == OB_FONT);
+}
+
 int ED_operator_editmesh(bContext *C)
 {
        Object *obedit= CTX_data_edit_object(C);