Fix #22603: Crash on launching external editor in texture paint [r29461] [WinXP 32bit]
authorSergey Sharybin <sergey.vfx@gmail.com>
Thu, 16 Sep 2010 15:54:48 +0000 (15:54 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Thu, 16 Sep 2010 15:54:48 +0000 (15:54 +0000)
Crash was caused by missed offscreen OpenGL buffer. Added checking around this stuff.
Also fixed crash of simple "Image from view operator".

Note: This commit fixes only crashing, you'll be still unable to use this tools.

release/scripts/op/image.py
source/blender/editors/sculpt_paint/paint_image.c

index 09c9f5e6881bcad283d57ab38fe2b0effdfdf71d..ca7a017febd8d3d4ddbf294fc40e639075a6983b 100644 (file)
@@ -121,7 +121,8 @@ class ProjectEdit(bpy.types.Operator):
         for image in bpy.data.images:
             image.tag = True
 
-        bpy.ops.paint.image_from_view()
+        if 'FINISHED' not in bpy.ops.paint.image_from_view():
+            return {'CANCELLED'}
 
         image_new = None
         for image in bpy.data.images:
index 4760796fdff78961a34a1ad8cd3d47cc130ee2e5..3f1a5af76b1ff16558be0af02d84ebb9a350c9e9 100644 (file)
@@ -5494,6 +5494,13 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
        if(h > maxsize) h= maxsize;
 
        ibuf= ED_view3d_draw_offscreen_imbuf(CTX_data_scene(C), CTX_wm_view3d(C), CTX_wm_region(C), w, h, IB_rect);
+       if(!ibuf) {
+               /* Mostly happens when OpenGL offscreen buffer was failed to create, */
+               /* but could be other reasons. Should be handled in the future. nazgul */
+               BKE_report(op->reports, RPT_ERROR, "Failed to create OpenGL offscreen buffer.");
+               return OPERATOR_CANCELLED;
+       }
+
        image= BKE_add_image_imbuf(ibuf);
 
        if(image) {