Fix #32408: image editor does not show paint brush circle on loading a .blend
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 31 Aug 2012 13:04:03 +0000 (13:04 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 31 Aug 2012 13:04:03 +0000 (13:04 +0000)
file that has paint mode enabled.

source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/util/ed_util.c
source/blender/makesrna/intern/rna_space.c

index 953215b83aa2d2adafa0dda1f81265fa32da113d..96f1f60a7e5dc064fde80e42f6b01feab1ab6308 100644 (file)
@@ -5334,12 +5334,25 @@ static void toggle_paint_cursor(bContext *C, int enable)
  * ensure that the cursor is hidden when not in paint mode */
 void ED_space_image_paint_update(wmWindowManager *wm, ToolSettings *settings)
 {
+       wmWindow *win;
+       ScrArea *sa;
        ImagePaintSettings *imapaint = &settings->imapaint;
+       int enabled = FALSE;
 
-       if (!imapaint->paintcursor) {
-               imapaint->paintcursor =
-                   WM_paint_cursor_activate(wm, image_paint_poll,
-                                            brush_drawcursor, NULL);
+       for (win = wm->windows.first; win; win = win->next)
+               for (sa = win->screen->areabase.first; sa; sa = sa->next)
+                       if (sa->spacetype == SPACE_IMAGE)
+                               if (((SpaceImage*)sa->spacedata.first)->mode == SI_MODE_PAINT)
+                                       enabled = TRUE;
+
+       if (enabled) {
+               BKE_paint_init(&imapaint->paint, PAINT_CURSOR_TEXTURE_PAINT);
+
+               if (!imapaint->paintcursor) {
+                       imapaint->paintcursor =
+                               WM_paint_cursor_activate(wm, image_paint_poll,
+                                                                                brush_drawcursor, NULL);
+               }
        }
 }
 
index 6d9f2732d8a903767860235a1c29a1ba55721db8..1f34793a972ec0874f705866a588759ffd4ca987 100644 (file)
@@ -49,6 +49,7 @@
 #include "BKE_packedFile.h"
 
 #include "ED_armature.h"
+#include "ED_image.h"
 #include "ED_mesh.h"
 #include "ED_object.h"
 #include "ED_sculpt.h"
@@ -67,6 +68,7 @@
 
 void ED_editors_init(bContext *C)
 {
+       wmWindowManager *wm = CTX_wm_manager(C);
        Main *bmain = CTX_data_main(C);
        Scene *sce = CTX_data_scene(C);
        Object *ob, *obact = (sce && sce->basact) ? sce->basact->object : NULL;
@@ -86,6 +88,9 @@ void ED_editors_init(bContext *C)
                                ED_object_toggle_modes(C, mode);
                }
        }
+
+       /* image editor paint mode */
+       ED_space_image_paint_update(wm, sce->toolsettings);
 }
 
 /* frees all editmode stuff */
index ad14c60e53237c256abac8cc7e3a4dd9a1241e6d..c4a60dba0256526af512137b097897850e51711d 100644 (file)
@@ -531,12 +531,7 @@ static PointerRNA rna_SpaceImageEditor_uvedit_get(PointerRNA *ptr)
 
 static void rna_SpaceImageEditor_mode_update(Main *bmain, Scene *scene, PointerRNA *ptr)
 {
-       SpaceImage *sima = (SpaceImage *)(ptr->data);
-       if (sima->mode == SI_MODE_PAINT) {
-               BKE_paint_init(&scene->toolsettings->imapaint.paint, PAINT_CURSOR_TEXTURE_PAINT);
-
-               ED_space_image_paint_update(bmain->wm.first, scene->toolsettings);
-       }
+       ED_space_image_paint_update(bmain->wm.first, scene->toolsettings);
 }
 
 static int rna_SpaceImageEditor_show_render_get(PointerRNA *ptr)