Fix #35683: Addon working fine in console. But crashed when click GUI button.
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 10 Jun 2013 09:45:51 +0000 (09:45 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 10 Jun 2013 09:45:51 +0000 (09:45 +0000)
Crash happened in ED_view3d_calc_zfac and happend in cases operator was invoked
from a region different from RGN_TYPE_WINDOW.

For a transformation zfac is only used in convertViewVec in cases region is
RGN_TYPE_WINDOW, so solved by just adding extra check in calculateCenter
for this particular case.

source/blender/editors/transform/transform_generics.c

index a2957263ba9a7ab9f54f23b41beb0141eec54606..6b0139aa8d9ceb6f9c1f094f1bc8229e6e3cd817 100644 (file)
@@ -1711,7 +1711,19 @@ void calculateCenter(TransInfo *t)
                else {
                        copy_v3_v3(vec, t->center);
                }
-               t->zfac = ED_view3d_calc_zfac(t->ar->regiondata, vec, NULL);
+
+               /* zfac is only used convertViewVec only in cases operator was invoked in RGN_TYPE_WINDOW
+                * and never used in other cases.
+                *
+                * We need special case here as well, since ED_view3d_calc_zfac will crahs when called
+                * for a region different from RGN_TYPE_WINDOW.
+                */
+               if (t->ar->regiontype == RGN_TYPE_WINDOW) {
+                       t->zfac = ED_view3d_calc_zfac(t->ar->regiondata, vec, NULL);
+               }
+               else {
+                       t->zfac = 0.0f;
+               }
        }
 }