svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r22130:22205
[blender-staging.git] / source / blender / windowmanager / intern / wm_init_exit.c
index 4bac829c80ab6f6820dccfc61c668a0825d6dd8f..599844f10202e94abda1c340e65b9ad0ae0f2f75 100644 (file)
 #include "BKE_global.h"
 #include "BKE_library.h"
 #include "BKE_mball.h"
+#include "BKE_report.h"
 #include "BKE_utildefines.h"
 #include "BKE_packedFile.h"
 
-#include "BMF_Api.h"
-#ifdef INTERNATIONAL
-#include "FTF_Api.h"
-#endif
-
 #include "BLI_blenlib.h"
 
 #include "RE_pipeline.h"               /* RE_ free stuff */
 
-#include "radio.h"
-
 #ifndef DISABLE_PYTHON
 #include "BPY_extern.h"
 #endif
 #include "wm_files.h"
 #include "wm_window.h"
 
+#include "ED_armature.h"
+#include "ED_keyframing.h"
+#include "ED_node.h"
+#include "ED_previewrender.h"
+#include "ED_space_api.h"
 #include "ED_screen.h"
 #include "ED_util.h"
 
 #include "UI_interface.h"
+#include "BLF_api.h"
 
 #include "GPU_extensions.h"
 #include "GPU_draw.h"
 
 
-static void initbuttons(void)
-{
-       UI_init();
-       
-//     glClearColor(.7f, .7f, .6f, 0.0);
-       
-       G.font= BMF_GetFont(BMF_kHelvetica12);
-       G.fonts= BMF_GetFont(BMF_kHelvetica10);
-       G.fontss= BMF_GetFont(BMF_kHelveticaBold8);
-       
-//     clear_matcopybuf(); /* XXX */
-       
-//     glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
-}
 
 /* XXX */
 static void sound_init_listener(void)
@@ -115,6 +101,18 @@ static void sound_init_listener(void)
        G.listener->dopplervelocity = 340.29f;
 }
 
+
+static void wm_init_reports(bContext *C)
+{
+       BKE_reports_init(CTX_wm_reports(C), RPT_STORE);
+}
+static void wm_free_reports(bContext *C)
+{
+       BKE_reports_clear(CTX_wm_reports(C));
+}
+
+
+
 /* only called once, for startup */
 void WM_init(bContext *C)
 {
@@ -126,22 +124,31 @@ void WM_init(bContext *C)
        set_free_windowmanager_cb(wm_close_and_free);   /* library.c */
        set_blender_test_break_cb(wm_window_testbreak); /* blender.c */
        
-       ED_spacetypes_init();   /* editors/area/spacetype.c */
-               
+       ED_spacetypes_init();   /* editors/space_api/spacetype.c */
+       
+       ED_file_init();                 /* for fsmenu */
+       ED_init_node_butfuncs();        
+       
+       BLF_init(11, U.dpi);
+       BLF_lang_init();
+       
+       init_builtin_keyingsets(); /* editors/animation/keyframing.c */
+       
        /* get the default database, plus a wm */
-       WM_read_homefile(C, 0);
+       WM_read_homefile(C, NULL);
+       
+       wm_init_reports(C); /* reports cant be initialized before the wm */
+       
+       UI_init();
+       
+       //      clear_matcopybuf(); /* XXX */
        
-       wm_check(C); /* opens window(s), checks keymaps */
+       //      glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
        
-//     initscreen();   /* for (visual) speed, this first, then setscreen */
-       initbuttons();
-//     InitCursorData();
        sound_init_listener();
 //     init_node_butfuncs();
        
-// XXX BIF_preview_init_dbase();
-       
-// XXX UI_filelist_init_icons();
+       ED_preview_init_dbase();
        
        GPU_extensions_init();
        
@@ -165,13 +172,13 @@ static void free_openrecent(void)
 
 /* bad stuff*/
 
-extern ListBase editNurb;
 extern ListBase editelems;
 extern wchar_t *copybuf;
 extern wchar_t *copybufinfo;
 
        // XXX copy/paste buffer stuff...
-extern void free_actcopybuf(); 
+extern void free_anim_copybuf(); 
+extern void free_posebuf(); 
 
 /* called in creator.c even... tsk, split this! */
 void WM_exit(bContext *C)
@@ -182,6 +189,9 @@ void WM_exit(bContext *C)
        /* modal handlers are on window level freed, others too? */
        /* note; same code copied in wm_files.c */
        if(C && CTX_wm_manager(C)) {
+               
+               WM_jobs_stop_all(CTX_wm_manager(C));
+               
                for(win= CTX_wm_manager(C)->windows.first; win; win= win->next) {
                        
                        CTX_wm_window_set(C, win);      /* needed by operator close callbacks */
@@ -194,9 +204,11 @@ void WM_exit(bContext *C)
        /* all non-screen and non-space stuff editors did, like editmode */
        if(C)
                ED_editors_exit(C);
-       
-       /* Context should still working here. but radio tool needs cleaning... */
-       freeAllRad(CTX_data_scene(C));
+
+//     XXX     
+//     BIF_GlobalReebFree();
+//     BIF_freeRetarget();
+       BIF_freeTemplates(C);
        
        free_ttfont(); /* bke_font.h */
        
@@ -214,24 +226,22 @@ void WM_exit(bContext *C)
        BPY_end_python();
 #endif
        
-//     fastshade_free_render();        /* shaded view */
-       free_blender();                         /* blender.c, does entire library */
+       fastshade_free_render();        /* shaded view */
+       ED_preview_free_dbase();        /* frees a Main dbase, before free_blender! */
+       wm_free_reports(C);                     /* before free_blender! - since the ListBases get freed there */
+       free_blender();                         /* blender.c, does entire library and spacetypes */
 //     free_matcopybuf();
-//     free_ipocopybuf();
-       free_actcopybuf();
+       free_anim_copybuf();
+       free_posebuf();
 //     free_vertexpaint();
 //     free_imagepaint();
        
-       /* editnurb can remain to exist outside editmode */
-       freeNurblist(&editNurb);
-       
 //     fsmenu_free();
-       
-#ifdef INTERNATIONAL
-//     free_languagemenu();
-#endif
-       
+
+       BLF_exit();
+
        RE_FreeAllRender();
+       RE_engines_exit();
        
 //     free_txt_data();
        
@@ -249,9 +259,7 @@ void WM_exit(bContext *C)
 // XXX         UI_filelist_free_icons();
        }
        
-#ifdef INTERNATIONAL
-       FTF_End();
-#endif
+       GPU_extensions_exit();
        
 //     if (copybuf) MEM_freeN(copybuf);
 //     if (copybufinfo) MEM_freeN(copybufinfo);
@@ -259,9 +267,10 @@ void WM_exit(bContext *C)
        BKE_undo_save_quit();   // saves quit.blend if global undo is on
        BKE_reset_undo(); 
        
+       ED_file_exit(); /* for fsmenu */
+
        UI_exit();
-       BLI_freelistN(&U.themes);
-// XXX BIF_preview_free_dbase();
+       BKE_userdef_free();
 
        RNA_exit();