=bmesh= merge from trunk at r36529
[blender.git] / source / blender / editors / transform / transform_generics.c
index efff37c74ea4c8105804bdc502134147d7a16636..9a19f1f3205ab9a9387e41ab6e3d5aef7b0e5acb 100644 (file)
@@ -967,7 +967,22 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
                t->options |= CTX_EDGE;
        }
 
-       t->spacetype = sa ? sa->spacetype : SPACE_EMPTY; /* background mode */
+
+       /* Assign the space type, some exceptions for running in different mode */
+       if(sa == NULL) {
+               /* background mode */
+               t->spacetype= SPACE_EMPTY;
+       }
+       else if ((ar == NULL) && (sa->spacetype == SPACE_VIEW3D)) {
+               /* running in the text editor */
+               t->spacetype= SPACE_EMPTY;
+       }
+       else {
+               /* normal operation */
+               t->spacetype= sa->spacetype;
+       }
+
+
        if(t->spacetype == SPACE_VIEW3D)
        {
                View3D *v3d = sa->spacedata.first;
@@ -1006,12 +1021,18 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
                        }
                }
        }
-       else if(t->spacetype==SPACE_IMAGE || t->spacetype==SPACE_NODE)
+       else if(t->spacetype==SPACE_IMAGE)
        {
                SpaceImage *sima = sa->spacedata.first;
-               // XXX for now, get View2D  from the active region
+               // XXX for now, get View2D from the active region
+               t->view = &ar->v2d;
+               t->around = sima->around;
+       }
+       else if(t->spacetype==SPACE_NODE)
+       {
+               // XXX for now, get View2D from the active region
                t->view = &ar->v2d;
-               t->around = (sima ? sima->around : 0);
+               t->around = V3D_CENTER;
        }
        else if(t->spacetype==SPACE_IPO) 
        {