2.5
[blender.git] / source / blender / windowmanager / intern / wm_init_exit.c
index ffc535c1d4611e386b13bf3a15b67bef77e61c99..4d170ceeb46478e105d65ab377fea6ed0d81ddb7 100644 (file)
 
 #include "SYS_System.h"
 
+#include "UI_interface.h"
+
+#include "RNA_define.h"
+
 #include "WM_api.h"
 #include "WM_types.h"
+
+#include "wm_cursors.h"
+#include "wm_event_system.h"
 #include "wm.h"
 #include "wm_files.h"
 #include "wm_window.h"
 
 static void initbuttons(void)
 {
-//     uiDefFont(UI_HELVB, 
-//                       BMF_GetFont(BMF_kHelveticaBold14), 
-//                       BMF_GetFont(BMF_kHelveticaBold12), 
-//                       BMF_GetFont(BMF_kHelveticaBold10), 
-//                       BMF_GetFont(BMF_kHelveticaBold8));
-//     uiDefFont(UI_HELV, 
-//                       BMF_GetFont(BMF_kHelvetica12), 
-//                       BMF_GetFont(BMF_kHelvetica12), 
-//                       BMF_GetFont(BMF_kHelvetica10), 
-//                       BMF_GetFont(BMF_kHelveticaBold8));
+       UI_init();
        
 //     glClearColor(.7f, .7f, .6f, 0.0);
        
@@ -114,6 +112,7 @@ void WM_init(bContext *C)
 {
        
        wm_ghost_init(C);       /* note: it assigns C to ghost! */
+       wm_init_cursor_data();
        wm_operatortype_init();
        
        set_free_windowmanager_cb(wm_close_and_free);   /* library.c */
@@ -133,10 +132,7 @@ void WM_init(bContext *C)
        
 // XXX BIF_preview_init_dbase();
        
-       
-// XXX BIF_resources_init();   /* after homefile, to dynamically load an icon file based on theme settings */
-       
-// XXX BIF_filelist_init_icons();
+// XXX UI_filelist_init_icons();
        
 //     init_gl_stuff();        /* drawview.c, after homefile */
        read_Blog();
@@ -165,6 +161,23 @@ extern wchar_t *copybufinfo;
 /* called in creator.c even... tsk, split this! */
 void WM_exit(bContext *C)
 {
+       wmWindow *win;
+       
+       /* first wrap up running stuff, we assume only the active WM is running */
+       /* modal handlers are on window level freed, others too? */
+       if(C && C->wm) {
+               for(win= C->wm->windows.first; win; win= win->next) {
+                       ARegion *ar;
+                       
+                       C->window= win; /* needed by operator close callbacks */
+                       WM_event_remove_handlers(C, &win->handlers);
+                       
+                       for(ar= win->screen->regionbase.first; ar; ar= ar->next)
+                               WM_event_remove_handlers(C, &ar->handlers);
+                       
+                       ED_screen_exit(C, win, win->screen);
+               }
+       }
        wm_operatortype_free();
        
        free_ttfont(); /* bke_font.h */
@@ -228,9 +241,7 @@ void WM_exit(bContext *C)
 #endif
        
        if (!G.background) {
-// XXX         BIF_resources_free();
-               
-// XXX         BIF_filelist_free_icons();
+// XXX         UI_filelist_free_icons();
        }
        
 #ifdef INTERNATIONAL
@@ -246,13 +257,16 @@ void WM_exit(bContext *C)
        BKE_undo_save_quit();   // saves quit.blend if global undo is on
        BKE_reset_undo(); 
        
+       UI_exit();
        BLI_freelistN(&U.themes);
 // XXX BIF_preview_free_dbase();
+
+       RNA_exit();
        
        MEM_freeN(C);
        
-       if(totblock!=0) {
-               printf("Error Totblock: %d\n",totblock);
+       if(MEM_get_memory_blocks_in_use()!=0) {
+               printf("Error Totblock: %d\n", MEM_get_memory_blocks_in_use());
                MEM_printmemlist();
        }
 //     delete_autosave();