merge with trunk at r31523
[blender.git] / source / blender / editors / util / ed_util.c
index 2796e7089328975a3c5dadbae32d2e7ac451c8ee..8e2a30b4a69f389f59ecff058b904200ada7ab84 100644 (file)
@@ -38,7 +38,6 @@
 #include "BLI_editVert.h"
 
 #include "BKE_context.h"
-#include "BKE_global.h"
 #include "BKE_main.h"
 
 #include "ED_armature.h"
@@ -77,13 +76,17 @@ void ED_editors_init(bContext *C)
 /* frees all editmode stuff */
 void ED_editors_exit(bContext *C)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *sce;
+
+       if(!bmain)
+               return;
        
        /* frees all editmode undos */
        undo_editmode_clear();
        ED_undo_paint_free();
        
-       for(sce=G.main->scene.first; sce; sce= sce->id.next) {
+       for(sce=bmain->scene.first; sce; sce= sce->id.next) {
                if(sce->obedit) {
                        Object *ob= sce->obedit;