merge from trunk at r31523
[blender.git] / source / blender / windowmanager / intern / wm_init_exit.c
index fe3172f5fdae674e53849f5967e0f2a5a8744fc4..0fd42ffb8aa6256c978837a18bf039a5981b20a1 100644 (file)
@@ -58,6 +58,7 @@
 #include "BKE_material.h" /* clear_matcopybuf */
 
 #include "BLI_blenlib.h"
+#include "BLI_cellalloc.h"
 
 #include "RE_pipeline.h"               /* RE_ free stuff */
 
@@ -95,6 +96,7 @@
 
 #include "BKE_depsgraph.h"
 #include "BKE_sound.h"
+#include "GHOST_C-api.h"
 
 static void wm_init_reports(bContext *C)
 {
@@ -213,11 +215,13 @@ int WM_init_game(bContext *C)
        ScrArea *sa;
        ARegion *ar;
 
-       Main *main = CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
 
-       if (!scene)
-               scene= main->scene.first;
+       if (!scene) {
+               // XXX, this should not be needed.
+               Main *bmain = CTX_data_main(C);
+               scene= bmain->scene.first;
+       }
 
        win = wm->windows.first;
 
@@ -264,8 +268,14 @@ int WM_init_game(bContext *C)
                /* Fullscreen */
                if(scene->gm.fullscreen) {
                        WM_operator_name_call(C, "WM_OT_window_fullscreen_toggle", WM_OP_EXEC_DEFAULT, NULL);
-                       ar->winrct.ymax = win->sizey;
-                       ar->winrct.xmax = win->sizex;
+                       wm_get_screensize(&ar->winrct.xmax, &ar->winrct.ymax);
+               }
+               else
+               {
+                       GHOST_RectangleHandle rect = GHOST_GetClientBounds(win->ghostwin);
+                       ar->winrct.ymax = GHOST_GetHeightRectangle(rect);
+                       ar->winrct.xmax = GHOST_GetWidthRectangle(rect);
+                       GHOST_DisposeRectangle(rect);
                }
 
                WM_operator_name_call(C, "VIEW3D_OT_game_start", WM_OP_EXEC_DEFAULT, NULL);
@@ -423,8 +433,11 @@ void WM_exit(bContext *C)
        
        SYS_DeleteSystem(SYS_GetSystem());
 
-       if(MEM_get_memory_blocks_in_use()!=0) {
-               printf("Error Totblock: %d\n", MEM_get_memory_blocks_in_use());
+       if(MEM_get_memory_blocks_in_use()!=0 || BLI_cellalloc_get_totblock()!=0) {
+               printf("Error Totblock: %d\n", 
+                       BLI_cellalloc_get_totblock()+MEM_get_memory_blocks_in_use());
+               BLI_cellalloc_printleaks();
+               BLI_cellalloc_destroy();
                MEM_printmemlist();
        }
        wm_autosave_delete();