svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r22717:22875
[blender.git] / source / blender / windowmanager / intern / wm_files.c
index c3b317590f16d717d70a4de51e61067de38a9760..9c30c99bbdd29ede1a74e805030f170e72eb0302 100644 (file)
@@ -68,6 +68,7 @@
 #include "BKE_main.h"
 #include "BKE_packedFile.h"
 #include "BKE_report.h"
+#include "BKE_sound.h"
 #include "BKE_texture.h"
 #include "BKE_utildefines.h"
 
@@ -224,7 +225,7 @@ static void wm_init_userdef()
 {
        UI_init_userdef();
        MEM_CacheLimiter_set_maximum(U.memcachelimit * 1024 * 1024);
-       
+       sound_init();
 }
 
 void WM_read_file(bContext *C, char *name, ReportList *reports)
@@ -252,7 +253,6 @@ void WM_read_file(bContext *C, char *name, ReportList *reports)
                wm_check(C); /* opens window(s), checks keymaps */
                
 // XXX         mainwindow_set_filename_to_title(G.main->name);
-// XXX         sound_initialize_sounds();
 
                if(retval==2) wm_init_userdef();        // in case a userdef is read from regular .blend
                
@@ -539,7 +539,7 @@ static void do_history(char *name, ReportList *reports)
                BKE_report(reports, RPT_ERROR, "Unable to make version backup");
 }
 
-void WM_write_file(bContext *C, char *target, ReportList *reports)
+void WM_write_file(bContext *C, char *target, int compress, ReportList *reports)
 {
        Library *li;
        int writeflags, len;
@@ -580,10 +580,11 @@ void WM_write_file(bContext *C, char *target, ReportList *reports)
 
        do_history(di, reports);
        
-       /* we use the UserDef to define compression flag */
-       writeflags= G.fileflags & ~G_FILE_COMPRESS;
-       if(U.flag & USER_FILECOMPRESS)
-               writeflags |= G_FILE_COMPRESS;
+       writeflags= G.fileflags;
+
+       /* set compression flag */
+       if(compress) writeflags |= G_FILE_COMPRESS;
+       else writeflags &= ~G_FILE_COMPRESS;
        
        if (BLO_write_file(CTX_data_main(C), di, writeflags, reports)) {
                strcpy(G.sce, di);
@@ -591,6 +592,9 @@ void WM_write_file(bContext *C, char *target, ReportList *reports)
                strcpy(G.main->name, di);       /* is guaranteed current file */
 
                G.save_over = 1; /* disable untitled.blend convention */
+
+               if(compress) G.fileflags |= G_FILE_COMPRESS;
+               else G.fileflags &= ~G_FILE_COMPRESS;
                
                writeBlog();
        }
@@ -601,11 +605,17 @@ void WM_write_file(bContext *C, char *target, ReportList *reports)
 /* operator entry */
 int WM_write_homefile(bContext *C, wmOperator *op)
 {
+       wmWindow *win= CTX_wm_window(C);
        char tstr[FILE_MAXDIR+FILE_MAXFILE];
        int write_flags;
        
+       /* check current window and close it if temp */
+       if(win->screen->full == SCREENTEMP) {
+               wm_window_close(C, win);
+       }
+       
        BLI_make_file_string("/", tstr, BLI_gethome(), ".B25.blend");
-               
+       
        /*  force save as regular blend file */
        write_flags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_LOCK | G_FILE_SIGN);