remove G.sce, use G.main->name instead.
authorCampbell Barton <ideasman42@gmail.com>
Mon, 18 Oct 2010 06:41:16 +0000 (06:41 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 18 Oct 2010 06:41:16 +0000 (06:41 +0000)
Both stored the filename of the blend file, but G.sce stored the last opened file.
This will make blender act differently in some cases since a relative path to the last opened file will no longer resolve (which is correct IMHO since that file isnt open and the path might not even be valid anymore).

Tested linking with durian files and rendering to relative paths when no files is loaded however we may need to have some operators give an error if they are used on the default startup.blend.

49 files changed:
source/blender/blenkernel/BKE_global.h
source/blender/blenkernel/intern/blender.c
source/blender/blenkernel/intern/customdata.c
source/blender/blenkernel/intern/image.c
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/packedFile.c
source/blender/blenkernel/intern/particle_system.c
source/blender/blenkernel/intern/pointcache.c
source/blender/blenkernel/intern/scene.c
source/blender/blenkernel/intern/sequencer.c
source/blender/blenkernel/intern/sound.c
source/blender/blenkernel/intern/text.c
source/blender/blenkernel/intern/writeavi.c
source/blender/blenkernel/intern/writeffmpeg.c
source/blender/blenlib/BLI_bpath.h
source/blender/blenlib/intern/bpath.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/collada/ImageExporter.cpp
source/blender/editors/interface/interface_draw.c
source/blender/editors/object/object_modifier.c
source/blender/editors/physics/physics_fluid.c
source/blender/editors/render/render_preview.c
source/blender/editors/render/render_shading.c
source/blender/editors/screen/screendump.c
source/blender/editors/space_buttons/buttons_ops.c
source/blender/editors/space_file/file_draw.c
source/blender/editors/space_file/file_ops.c
source/blender/editors/space_file/filelist.c
source/blender/editors/space_file/filesel.c
source/blender/editors/space_file/writeimage.c
source/blender/editors/space_image/image_ops.c
source/blender/editors/space_info/info_ops.c
source/blender/editors/space_outliner/outliner.c
source/blender/editors/space_sequencer/sequencer_add.c
source/blender/editors/space_sequencer/sequencer_edit.c
source/blender/editors/space_text/text_ops.c
source/blender/makesrna/intern/rna_image_api.c
source/blender/modifiers/intern/MOD_fluidsim_util.c
source/blender/python/generic/bpy_internal_import.c
source/blender/quicktime/apple/quicktime_export.c
source/blender/render/intern/source/pipeline.c
source/blender/windowmanager/intern/wm_files.c
source/blender/windowmanager/intern/wm_init_exit.c
source/blender/windowmanager/intern/wm_operators.c
source/blender/windowmanager/intern/wm_window.c
source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
source/gameengine/BlenderRoutines/KX_BlenderGL.cpp
source/gameengine/GamePlayer/ghost/GPG_ghost.cpp

index 6a602339e111cda407c689b7275dc58bef47a18e..76fb5605d77056af14d54de3b0d6be53a36a2a6c 100644 (file)
@@ -52,9 +52,9 @@ typedef struct Global {
        struct Main *main;
        
        /* strings: lastsaved */
-       char ima[256], sce[256], lib[256];
+       char ima[256], lib[256];
 
-       /* flag: if != 0 G.sce contains valid relative base path */
+       /* flag: if != 0 G.main->name contains valid relative base path */
        int relbase_valid;
 
        /* strings of recent opend files */
index 5fcf3c77d3be2dac5414d8a04c3b5327087ae8fb..72d194e4d79c0c61c09c81551482349113d6df4d 100644 (file)
@@ -309,8 +309,8 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, char *filename)
 #endif
        
        /* these are the same at times, should never copy to the same location */
-       if(G.sce != filename)
-               BLI_strncpy(G.sce, filename, FILE_MAX);
+       if(G.main->name != filename)
+               BLI_strncpy(G.main->name, filename, FILE_MAX);
        
        BLI_strncpy(G.main->name, filename, FILE_MAX); /* is guaranteed current file */
 
@@ -410,7 +410,7 @@ int BKE_read_file_from_memfile(bContext *C, MemFile *memfile, ReportList *report
 {
        BlendFileData *bfd;
 
-       bfd= BLO_read_from_memfile(CTX_data_main(C), G.sce, memfile, reports);
+       bfd= BLO_read_from_memfile(CTX_data_main(C), G.main->name, memfile, reports);
        if (bfd)
                setup_app_data(C, bfd, "<memory1>");
        else
@@ -460,14 +460,12 @@ static UndoElem *curundo= NULL;
 
 static int read_undosave(bContext *C, UndoElem *uel)
 {
-       char scestr[FILE_MAXDIR+FILE_MAXFILE]; /* we should eventually just use G.main->name */
        char mainstr[FILE_MAXDIR+FILE_MAXFILE];
        int success=0, fileflags;
        
        /* This is needed so undoing/redoing doesnt crash with threaded previews going */
        WM_jobs_stop_all(CTX_wm_manager(C));
-       
-       strcpy(scestr, G.sce);  /* temporal store */
+
        strcpy(mainstr, G.main->name);  /* temporal store */
 
        fileflags= G.fileflags;
@@ -479,7 +477,6 @@ static int read_undosave(bContext *C, UndoElem *uel)
                success= BKE_read_file_from_memfile(C, &uel->memfile, NULL);
 
        /* restore */
-       strcpy(G.sce, scestr); /* restore */
        strcpy(G.main->name, mainstr); /* restore */
        G.fileflags= fileflags;
 
@@ -720,7 +717,7 @@ void BKE_undo_save_quit(void)
 Main *BKE_undo_get_main(Scene **scene)
 {
        Main *mainp= NULL;
-       BlendFileData *bfd= BLO_read_from_memfile(G.main, G.sce, &curundo->memfile, NULL);
+       BlendFileData *bfd= BLO_read_from_memfile(G.main, G.main->name, &curundo->memfile, NULL);
        
        if(bfd) {
                mainp= bfd->main;
index 7f91df3b28189d3e3a74305c65efa974855d9d45..9c4f0d790cab0c04c11f44eda066c4a49f59c161 100644 (file)
@@ -48,6 +48,7 @@
 #include "BKE_customdata.h"
 #include "BKE_customdata_file.h"
 #include "BKE_global.h"
+#include "BKE_main.h"
 #include "BKE_utildefines.h"
 
 /* number of layers to add when growing a CustomData object */
@@ -2343,7 +2344,7 @@ int CustomData_verify_versions(struct CustomData *data, int index)
 
 static void customdata_external_filename(char filename[FILE_MAX], ID *id, CustomDataExternal *external)
 {
-       char *path = (id->lib)? id->lib->filepath: G.sce;
+       char *path = (id->lib)? id->lib->filepath: G.main->name;
 
        BLI_strncpy(filename, external->filename, FILE_MAX);
        BLI_path_abs(filename, path);
index 8ba7cde519d49f8bbf0d041c6efa51a55ed6e74e..09622b2acfe5fde09a31a51ae142d790641b88a7 100644 (file)
@@ -338,7 +338,7 @@ Image *BKE_add_image_file(const char *name)
        char str[FILE_MAX], strtest[FILE_MAX];
        
        BLI_strncpy(str, name, sizeof(str));
-       BLI_path_abs(str, G.sce);
+       BLI_path_abs(str, G.main->name);
        
        /* exists? */
        file= open(str, O_BINARY|O_RDONLY);
@@ -349,7 +349,7 @@ Image *BKE_add_image_file(const char *name)
        for(ima= G.main->image.first; ima; ima= ima->id.next) {
                if(ima->source!=IMA_SRC_VIEWER && ima->source!=IMA_SRC_GENERATED) {
                        BLI_strncpy(strtest, ima->name, sizeof(ima->name));
-                       BLI_path_abs(strtest, G.sce);
+                       BLI_path_abs(strtest, G.main->name);
                        
                        if( strcmp(strtest, str)==0 ) {
                                if(ima->anim==NULL || ima->id.us==0) {
@@ -861,8 +861,8 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix)
 
        if (scene->r.stamp & R_STAMP_FILENAME) {
                if (G.relbase_valid) {
-                       if (do_prefix)          sprintf(stamp_data->file, "File %s", G.sce);
-                       else                            sprintf(stamp_data->file, "%s", G.sce);
+                       if (do_prefix)          sprintf(stamp_data->file, "File %s", G.main->name);
+                       else                            sprintf(stamp_data->file, "%s", G.main->name);
                } else {
                        if (do_prefix)          strcpy(stamp_data->file, "File <untitled>");
                        else                            strcpy(stamp_data->file, "<untitled>");
@@ -1311,7 +1311,7 @@ void BKE_makepicstring(char *string, char *base, int frame, int imtype, int use_
 {
        if (string==NULL) return;
        BLI_strncpy(string, base, FILE_MAX - 10);       /* weak assumption */
-       BLI_path_abs(string, G.sce);
+       BLI_path_abs(string, G.main->name);
        BLI_path_frame(string, frame, 4);
 
        if(use_ext)
@@ -1609,7 +1609,7 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame)
        if(ima->id.lib)
                BLI_path_abs(name, ima->id.lib->filepath);
        else
-               BLI_path_abs(name, G.sce);
+               BLI_path_abs(name, G.main->name);
        
        flag= IB_rect|IB_multilayer;
        if(ima->flag & IMA_DO_PREMUL)
@@ -1717,7 +1717,7 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame)
                if(ima->id.lib)
                        BLI_path_abs(str, ima->id.lib->filepath);
                else
-                       BLI_path_abs(str, G.sce);
+                       BLI_path_abs(str, G.main->name);
                
                ima->anim = openanim(str, IB_rect);
                
@@ -1778,7 +1778,7 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra)
                if(ima->id.lib)
                        BLI_path_abs(str, ima->id.lib->filepath);
                else
-                       BLI_path_abs(str, G.sce);
+                       BLI_path_abs(str, G.main->name);
                
                /* read ibuf */
                ibuf = IMB_loadiffname(str, flag);
index 1e08432c271b43d9dc9e52599b2398dfc6992893..dfc82152e8c17d64eed95465e48372284699004a 100644 (file)
@@ -1234,7 +1234,7 @@ static void image_fix_relative_path(Image *ima)
        if(ima->id.lib==NULL) return;
        if(strncmp(ima->name, "//", 2)==0) {
                BLI_path_abs(ima->name, ima->id.lib->filepath);
-               BLI_path_rel(ima->name, G.sce);
+               BLI_path_rel(ima->name, G.main->name);
        }
 }
 
index 5bbb3506a780fb343fa0785a92d15367ca9700c4..33f1949c5accc322da030e311b75b4e93893c6ca 100644 (file)
@@ -179,7 +179,7 @@ PackedFile *newPackedFile(ReportList *reports, char *filename)
        // convert relative filenames to absolute filenames
        
        strcpy(name, filename);
-       BLI_path_abs(name, G.sce);
+       BLI_path_abs(name, G.main->name);
        
        // open the file
        // and create a PackedFile structure
@@ -274,7 +274,7 @@ int writePackedFile(ReportList *reports, char *filename, PackedFile *pf, int gui
        if (guimode) {} //XXX  waitcursor(1);
        
        strcpy(name, filename);
-       BLI_path_abs(name, G.sce);
+       BLI_path_abs(name, G.main->name);
        
        if (BLI_exists(name)) {
                for (number = 1; number <= 999; number++) {
@@ -339,7 +339,7 @@ int checkPackedFile(char *filename, PackedFile *pf)
        char name[FILE_MAXDIR + FILE_MAXFILE];
        
        strcpy(name, filename);
-       BLI_path_abs(name, G.sce);
+       BLI_path_abs(name, G.main->name);
        
        if (stat(name, &st)) {
                ret_val = PF_NOFILE;
index 8ab4117c8a122cef866a57c32c2044b113aa3ae8..71ec1114848089fce0f94374f809c064553e8a86 100644 (file)
@@ -63,6 +63,7 @@
 #include "BLI_listbase.h"
 #include "BLI_threads.h"
 
+#include "BKE_main.h"
 #include "BKE_animsys.h"
 #include "BKE_boids.h"
 #include "BKE_cdderivedmesh.h"
@@ -3607,7 +3608,7 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra))
                        // ok, start loading
                        strcpy(filename, fss->surfdataPath);
                        strcat(filename, suffix);
-                       BLI_path_abs(filename, G.sce);
+                       BLI_path_abs(filename, G.main->name);
                        BLI_path_frame(filename, curFrame, 0); // fixed #frame-no 
                        strcat(filename, suffix2);
        
index 3896d523b1119311ff82ff3a450ffe30320a9b91..37d2b103ef0ad3f3eaf71bc8d019647c1c1d87f4 100644 (file)
@@ -1085,7 +1085,7 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int dup
 static int ptcache_path(PTCacheID *pid, char *filename)
 {
        Library *lib= (pid->ob)? pid->ob->id.lib: NULL;
-       const char *blendfilename= (lib && (pid->cache->flag & PTCACHE_IGNORE_LIBPATH)==0) ? lib->filepath: G.sce;
+       const char *blendfilename= (lib && (pid->cache->flag & PTCACHE_IGNORE_LIBPATH)==0) ? lib->filepath: G.main->name;
        size_t i;
 
        if(pid->cache->flag & PTCACHE_EXTERNAL) {
index fde180cadc66aae01107bc6db95ca0832b39a528..e399e0bb83dc29250e0c4072e1753dee67ee1a24 100644 (file)
@@ -566,11 +566,11 @@ Scene *set_scene_name(Main *bmain, char *name)
        Scene *sce= (Scene *)find_id("SC", name);
        if(sce) {
                set_scene_bg(bmain, sce);
-               printf("Scene switch: '%s' in file: '%s'\n", name, G.sce);
+               printf("Scene switch: '%s' in file: '%s'\n", name, G.main->name);
                return sce;
        }
 
-       printf("Can't find scene: '%s' in file: '%s'\n", name, G.sce);
+       printf("Can't find scene: '%s' in file: '%s'\n", name, G.main->name);
        return NULL;
 }
 
index 6d087837302873b65f875f93b8c10e01cdad5400..21b7cfd010c42389dd01033a2fb1385af06c31e3 100644 (file)
@@ -579,7 +579,7 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq, int lock_range)
        if (seq->type != SEQ_SCENE && seq->type != SEQ_META &&
                seq->type != SEQ_IMAGE) {
                BLI_join_dirfile(str, seq->strip->dir, seq->strip->stripdata->name);
-               BLI_path_abs(str, G.sce);
+               BLI_path_abs(str, G.main->name);
        }
 
        if (seq->type == SEQ_IMAGE) {
@@ -1044,7 +1044,7 @@ static int seq_proxy_get_fname(Scene *UNUSED(scene), Sequence * seq, int cfra, c
 
        if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) {
                BLI_join_dirfile(name, dir, seq->strip->proxy->file);
-               BLI_path_abs(name, G.sce);
+               BLI_path_abs(name, G.main->name);
 
                return TRUE;
        }
@@ -1071,7 +1071,7 @@ static int seq_proxy_get_fname(Scene *UNUSED(scene), Sequence * seq, int cfra, c
                         render_size);
        }
 
-       BLI_path_abs(name, G.sce);
+       BLI_path_abs(name, G.main->name);
        BLI_path_frame(name, frameno, 0);
 
 
@@ -2002,7 +2002,7 @@ static ImBuf * seq_render_strip(Main *bmain, Scene *scene, Sequence * seq, float
 
                if(ibuf == 0 && s_elem) {
                        BLI_join_dirfile(name, seq->strip->dir, s_elem->name);
-                       BLI_path_abs(name, G.sce);
+                       BLI_path_abs(name, G.main->name);
 
                        ibuf = seq_proxy_fetch(scene, seq, cfra, render_size);
                }
@@ -2038,7 +2038,7 @@ static ImBuf * seq_render_strip(Main *bmain, Scene *scene, Sequence * seq, float
                                BLI_join_dirfile(name, 
                                                 seq->strip->dir, 
                                                 seq->strip->stripdata->name);
-                               BLI_path_abs(name, G.sce);
+                               BLI_path_abs(name, G.main->name);
                                        
                                seq->anim = openanim(
                                        name, IB_rect | 
@@ -3492,7 +3492,7 @@ Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo
        struct anim *an;
 
        BLI_strncpy(path, seq_load->path, sizeof(path));
-       BLI_path_abs(path, G.sce);
+       BLI_path_abs(path, G.main->name);
 
        an = openanim(path, IB_rect);
 
index 5c3047942f77c9933b6967d07fd271f6bb88ecc9..cc941c81131f636b874842a17a38bc6f980cbd68 100644 (file)
@@ -131,7 +131,7 @@ struct bSound* sound_new_file(struct Main *bmain, char* filename)
 
        strcpy(str, filename);
 
-       path = /*bmain ? bmain->name :*/ G.sce;
+       path = /*bmain ? bmain->name :*/ G.main->name;
 
        BLI_path_abs(str, path);
 
@@ -267,7 +267,7 @@ void sound_load(struct Main *UNUSED(bmain), struct bSound* sound)
                                path = sound->id.lib->filepath;
                        else
                                // XXX this should be fixed!
-                               path = /*bmain ? bmain->name :*/ G.sce;
+                               path = /*bmain ? bmain->name :*/ G.main->name;
 
                        BLI_path_abs(fullpath, path);
 
index 19bc853276a0c912a44d4530a34052cb815b2dfd..bb1a1a88a094d0d8a88b7228f37a3dd186880c32 100644 (file)
@@ -241,7 +241,7 @@ int reopen_text(Text *text)
        if (!text || !text->name) return 0;
        
        BLI_strncpy(str, text->name, FILE_MAXDIR+FILE_MAXFILE);
-       BLI_path_abs(str, G.sce);
+       BLI_path_abs(str, G.main->name);
        
        fp= fopen(str, "r");
        if(fp==NULL) return 0;
index 8363ff13ef94cffb1c378dc5691a27bd7a9c8524..de708f216fd5bc756c3b88041a777c4ad3f848fa 100644 (file)
@@ -40,6 +40,7 @@
 #include "BLI_blenlib.h"
 
 #include "BKE_global.h"
+#include "BKE_main.h"
 #include "BKE_report.h"
 #include "BKE_utildefines.h"
 #include "BKE_writeavi.h"
@@ -119,7 +120,7 @@ static void filepath_avi (char *string, RenderData *rd)
        if (string==NULL) return;
 
        strcpy(string, rd->pic);
-       BLI_path_abs(string, G.sce);
+       BLI_path_abs(string, G.main->name);
 
        BLI_make_existing_file(string);
 
index 473c10d6ced6106bfec85e37147a8199f0ecfbb3..ec998e68e00bf16f9ecfa08457f7b3e9808bb8b5 100644 (file)
@@ -857,7 +857,7 @@ void filepath_ffmpeg(char* string, RenderData* rd) {
        if (!string || !exts) return;
 
        strcpy(string, rd->pic);
-       BLI_path_abs(string, G.sce);
+       BLI_path_abs(string, G.main->name);
 
        BLI_make_existing_file(string);
 
index 72489a171b983f657cf868ea0c27321e274de19e..34b9e28206124ed4e05948e2c0dc170dd48a94a7 100644 (file)
@@ -50,7 +50,7 @@ struct BPathIterator {
        void (*setpath_callback)(struct BPathIterator *, char *);
        void (*getpath_callback)(struct BPathIterator *, char *);
        
-       char*   base_path; /* base path, the directry the blend file is in - normally G.sce */
+       char*   base_path; /* base path, the directry the blend file is in - normally G.main->name */
 
        /* only for seq data */
        struct BPathIteratorSeqData seqdata;
index cf7eb8734096c79773f69de40ec8fec456461331..862df4103a7f0eb5d69e9f62bab35286c4136204 100644 (file)
@@ -92,7 +92,7 @@ void BLI_bpathIterator_init( struct BPathIterator *bpi, char *base_path ) {
        bpi->seqdata.seqar = NULL;
        bpi->seqdata.scene = NULL;
        
-       bpi->base_path= base_path ? base_path : G.sce;
+       bpi->base_path= base_path ? base_path : G.main->name;
 
        BLI_bpathIterator_step(bpi);
 }
index ebd407e7e215c8786547b2867c5e9a3ef173c32b..b6515863c2b04166daeaa3d95969e37879c2fa87 100644 (file)
@@ -9707,7 +9707,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                        {
                                                char str[FILE_MAX];
                                                BLI_join_dirfile(str, seq->strip->dir, seq->strip->stripdata->name);
-                                               BLI_path_abs(str, G.sce);
+                                               BLI_path_abs(str, G.main->name);
                                                seq->sound = sound_new_file(main, str);
                                        }
                                        /* don't know, if anybody used that
@@ -12369,7 +12369,7 @@ static Main* library_append_begin(const bContext *C, FileData **fd, char *dir)
        blo_split_main(&(*fd)->mainlist, mainvar);
 
        /* which one do we need? */
-       mainl = blo_find_main(*fd, &(*fd)->mainlist, dir, G.sce);
+       mainl = blo_find_main(*fd, &(*fd)->mainlist, dir, G.main->name);
        
        /* needed for do_version */
        mainl->versionfile= (*fd)->fileversion;
@@ -12453,7 +12453,7 @@ static void library_append_end(const bContext *C, Main *mainl, FileData **fd, in
                BLI_strncpy(curlib->name, curlib->filepath, sizeof(curlib->name));
                
                /* uses current .blend file as reference */
-               BLI_path_rel(curlib->name, G.sce);
+               BLI_path_rel(curlib->name, G.main->name);
        }
 
        blo_join_main(&(*fd)->mainlist);
@@ -12462,7 +12462,7 @@ static void library_append_end(const bContext *C, Main *mainl, FileData **fd, in
 
        lib_link_all(*fd, mainvar);
        lib_verify_nodetree(mainvar, FALSE);
-       fix_relpaths_library(G.sce, mainvar); /* make all relative paths, relative to the open blend file */
+       fix_relpaths_library(G.main->name, mainvar); /* make all relative paths, relative to the open blend file */
 
        /* give a base to loose objects. If group append, do it for objects too */
        if(scene) {
@@ -12578,7 +12578,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
                                                while(fd==NULL) {
                                                        char newlib_path[240] = { 0 };
                                                        printf("Missing library...'\n");
-                                                       printf("        current file: %s\n", G.sce);
+                                                       printf("        current file: %s\n", G.main->name);
                                                        printf("        absolute lib: %s\n", mainptr->curlib->filepath);
                                                        printf("        relative lib: %s\n", mainptr->curlib->name);
                                                        printf("  enter a new path:\n");
@@ -12586,7 +12586,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
                                                        if(scanf("%s", newlib_path) > 0) {
                                                                strcpy(mainptr->curlib->name, newlib_path);
                                                                strcpy(mainptr->curlib->filepath, newlib_path);
-                                                               cleanup_path(G.sce, mainptr->curlib->filepath);
+                                                               cleanup_path(G.main->name, mainptr->curlib->filepath);
                                                                
                                                                fd= blo_openblenderfile(mainptr->curlib->filepath, basefd->reports);
 
index 440f1cc98a89316747d17e9a3d8d100064d4d43d..b5715353c6c754f334acee9dfec094abb933c5f2 100644 (file)
@@ -2471,14 +2471,14 @@ int BLO_write_file(Main *mainvar, char *dir, int write_flags, ReportList *report
                if(strcmp(dir1, dir2)==0)
                        write_flags &= ~G_FILE_RELATIVE_REMAP;
                else
-                       makeFilesAbsolute(G.sce, NULL);
+                       makeFilesAbsolute(G.main->name, NULL);
        }
 
-       BLI_make_file_string(G.sce, userfilename, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_STARTUP_FILE);
+       BLI_make_file_string(G.main->name, userfilename, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_STARTUP_FILE);
        write_user_block= BLI_streq(dir, userfilename);
 
        if(write_flags & G_FILE_RELATIVE_REMAP)
-               makeFilesRelative(dir, NULL); /* note, making relative to something OTHER then G.sce */
+               makeFilesRelative(dir, NULL); /* note, making relative to something OTHER then G.main->name */
 
        /* actual file writing */
        err= write_file_handle(mainvar, file, NULL,NULL, write_user_block, write_flags, thumb);
index ce40846ba593ab83a360cc549df474dd064e390f..3194b2269ea0d5e097b1c46bce090d4617ee58e4 100644 (file)
@@ -32,6 +32,7 @@
 #include "DNA_texture_types.h"
 
 #include "BKE_global.h"
+#include "BKE_main.h"
 #include "BKE_utildefines.h"
 #include "BLI_fileops.h"
 #include "BLI_path_util.h"
@@ -66,13 +67,13 @@ void ImagesExporter::operator()(Material *ma, Object *ob)
                        
                        BLI_split_dirfile(mfilename, dir, NULL);
 
-                       BKE_rebase_path(abs, sizeof(abs), rel, sizeof(rel), G.sce, image->name, dir);
+                       BKE_rebase_path(abs, sizeof(abs), rel, sizeof(rel), G.main->name, image->name, dir);
 
                        if (abs[0] != '\0') {
 
                                // make absolute source path
                                BLI_strncpy(src, image->name, sizeof(src));
-                               BLI_path_abs(src, G.sce);
+                               BLI_path_abs(src, G.main->name);
 
                                // make dest directory if it doesn't exist
                                BLI_make_existing_file(abs);
index 855ca45f61a44c86b00427d294b4930c76c876a6..81b04fea06210ac92a8601433efd80419afb7eda 100644 (file)
@@ -564,7 +564,7 @@ static void ui_draw_but_CHARTAB(uiBut *but)
                        int err;
 
                        strcpy(tmpStr, G.selfont->name);
-                       BLI_path_abs(tmpStr, G.sce);
+                       BLI_path_abs(tmpStr, G.main->name);
                        err = FTF_SetFont((unsigned char *)tmpStr, 0, 14.0);
                }
        }
index 3bdf202aca9fe211c95b366ab20c61a65a4dbf90..c273b375a06e3e22927adc50c0195d6308940ca6 100644 (file)
@@ -1058,7 +1058,7 @@ static int multires_external_save_exec(bContext *C, wmOperator *op)
        RNA_string_get(op->ptr, "filepath", path);
 
        if(relative)
-               BLI_path_rel(path, G.sce);
+               BLI_path_rel(path, G.main->name);
 
        CustomData_external_add(&me->fdata, &me->id, CD_MDISPS, me->totface, path);
        CustomData_external_write(&me->fdata, &me->id, CD_MASK_MESH, me->totface, 0);
index 6dc4684d815f75571d860af64613fee550331e02..b1c373e7a91853697f2c16d0bd0273ed8b0447b3 100644 (file)
@@ -639,7 +639,7 @@ static int fluid_init_filepaths(Object *fsDomain, char *targetDir, char *targetF
        // prepare names...
        strncpy(targetDir, domainSettings->surfdataPath, FILE_MAXDIR);
        strncpy(newSurfdataPath, domainSettings->surfdataPath, FILE_MAXDIR);
-       BLI_path_abs(targetDir, G.sce); // fixed #frame-no 
+       BLI_path_abs(targetDir, G.main->name); // fixed #frame-no 
        
        strcpy(targetFile, targetDir);
        strcat(targetFile, suffixConfig);
@@ -663,7 +663,7 @@ static int fluid_init_filepaths(Object *fsDomain, char *targetDir, char *targetF
                char blendFile[FILE_MAXDIR+FILE_MAXFILE];
                
                // invalid dir, reset to current/previous
-               strcpy(blendDir, G.sce);
+               strcpy(blendDir, G.main->name);
                BLI_splitdirstring(blendDir, blendFile);
                if(strlen(blendFile)>6){
                        int len = strlen(blendFile);
@@ -694,7 +694,7 @@ static int fluid_init_filepaths(Object *fsDomain, char *targetDir, char *targetF
                if(selection<1) return 0; // 0 from menu, or -1 aborted
                strcpy(targetDir, newSurfdataPath);
                strncpy(domainSettings->surfdataPath, newSurfdataPath, FILE_MAXDIR);
-               BLI_path_abs(targetDir, G.sce); // fixed #frame-no 
+               BLI_path_abs(targetDir, G.main->name); // fixed #frame-no 
        }
 #endif 
        return outStringsChanged;
index 21f10d936bf1ada1ae1f96402e6e7e873adaa7ad..0e8587e46427dcf3e8055b0c741278c2d76a7220 100644 (file)
@@ -111,7 +111,7 @@ ImBuf* get_brush_icon(Brush *brush)
                                // first use the path directly to try and load the file
 
                                BLI_strncpy(path, brush->icon_filepath, sizeof(brush->icon_filepath));
-                               BLI_path_abs(path, G.sce);
+                               BLI_path_abs(path, G.main->name);
 
                                brush->icon_imbuf= IMB_loadiffname(path, flags);
 
@@ -121,7 +121,7 @@ ImBuf* get_brush_icon(Brush *brush)
 
                                        path[0]= 0;
 
-                                       BLI_make_file_string(G.sce, path, folder, brush->icon_filepath);
+                                       BLI_make_file_string(G.main->name, path, folder, brush->icon_filepath);
 
                                        if (path[0])
                                                brush->icon_imbuf= IMB_loadiffname(path, flags);
index bca8100a809c9be1f387a962efa9a11ce278e1f7..9db15ee43e5bb31b68a29c901fa65efbda7d6987 100644 (file)
@@ -852,7 +852,7 @@ static int save_envmap(wmOperator *op, Scene *scene, EnvMap *env, char *str, int
                ibuf->profile = IB_PROFILE_LINEAR_RGB;
        
        /* to save, we first get absolute path */
-       BLI_path_abs(str, G.sce);
+       BLI_path_abs(str, G.main->name);
        
        if (BKE_write_ibuf(scene, ibuf, str, imtype, scene->r.subimtype, scene->r.quality)) {
                retval = OPERATOR_FINISHED;
@@ -863,7 +863,7 @@ static int save_envmap(wmOperator *op, Scene *scene, EnvMap *env, char *str, int
        }
        /* in case we were saving with relative paths, change back again */
        if(relative)
-               BLI_path_rel(str, G.sce);
+               BLI_path_rel(str, G.main->name);
        
        IMB_freeImBuf(ibuf);
        ibuf = NULL;
@@ -908,7 +908,7 @@ static int envmap_save_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event
 
        //RNA_enum_set(op->ptr, "file_type", scene->r.imtype);
        
-       RNA_string_set(op->ptr, "filepath", G.sce);
+       RNA_string_set(op->ptr, "filepath", G.main->name);
        WM_event_add_fileselect(C, op);
        
        return OPERATOR_RUNNING_MODAL;
index 937441a6e4344debe02d85aadbf97fdb8909b312..082c9f2f721cd098585c3124dfaa030ef68a31d1 100644 (file)
@@ -42,6 +42,7 @@
 
 #include "BKE_context.h"
 #include "BKE_global.h"
+#include "BKE_main.h"
 #include "BKE_image.h"
 #include "BKE_report.h"
 #include "BKE_writeavi.h"
@@ -77,7 +78,7 @@ static int screenshot_exec(bContext *C, wmOperator *op)
                RNA_string_get(op->ptr, "filepath", path);
        
                strcpy(G.ima, path);
-               BLI_path_abs(path, G.sce);
+               BLI_path_abs(path, G.main->name);
                
                /* BKE_add_image_extension() checks for if extension was already set */
                if(scene->r.scemode & R_EXTENSION) 
index 2573470e8df994b1c90ef5b91f94189143bd706a..e72446366fe1a67a5b1e57b354e8eca2ab20a0f9 100644 (file)
@@ -39,6 +39,7 @@
 
 #include "BKE_context.h"
 #include "BKE_global.h"
+#include "BKE_main.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
@@ -104,7 +105,7 @@ static int file_browse_exec(bContext *C, wmOperator *op)
        /* add slash for directories, important for some properties */
        if(RNA_property_subtype(fbo->prop) == PROP_DIRPATH) {
                id = fbo->ptr.id.data;
-               base = (id && id->lib)? id->lib->filepath: G.sce;
+               base = (id && id->lib)? id->lib->filepath: G.main->name;
 
                BLI_strncpy(path, str, FILE_MAX);
                BLI_path_abs(path, base);
index 421b14e5bbeaaceeac10e8393493f0dbaf18f415..65415d382ec7cddacff6c48f7c0255c1a60ce1ff 100644 (file)
@@ -40,6 +40,7 @@
 
 #include "BKE_context.h"
 #include "BKE_global.h"
+#include "BKE_main.h"
 
 #include "BLF_api.h"
 
@@ -445,9 +446,9 @@ static void renamebutton_cb(bContext *C, void *UNUSED(arg1), char *oldname)
        struct direntry *file = (struct direntry *)arg1;
 #endif
 
-       BLI_make_file_string(G.sce, orgname, sfile->params->dir, oldname);
+       BLI_make_file_string(G.main->name, orgname, sfile->params->dir, oldname);
        BLI_strncpy(filename, sfile->params->renameedit, sizeof(filename));
-       BLI_make_file_string(G.sce, newname, sfile->params->dir, filename);
+       BLI_make_file_string(G.main->name, newname, sfile->params->dir, filename);
 
        if( strcmp(orgname, newname) != 0 ) {
                if (!BLI_exists(newname)) {
index 6dfdcfd430a290e46001e7141c127e599bbd2885..1af8e9d14be959feac697526ad8bebb20bc6b852 100644 (file)
@@ -30,6 +30,7 @@
 #include "BKE_screen.h"
 #include "BKE_global.h"
 #include "BKE_report.h"
+#include "BKE_main.h"
 
 #include "BLI_blenlib.h"
 #include "BLI_storage_types.h"
@@ -190,7 +191,7 @@ static FileSelect file_select(bContext* C, const rcti* rect, short selecting, sh
                                        /* avoids /../../ */     
                                        BLI_parent_dir(params->dir);     
                                } else {
-                                       BLI_cleanup_dir(G.sce, params->dir);
+                                       BLI_cleanup_dir(G.main->name, params->dir);
                                        strcat(params->dir, file->relname);
                                        BLI_add_slash(params->dir);
                                }
@@ -361,7 +362,7 @@ static int bookmark_select_exec(bContext *C, wmOperator *op)
 
                RNA_string_get(op->ptr, "dir", entry);
                BLI_strncpy(params->dir, entry, sizeof(params->dir));
-               BLI_cleanup_dir(G.sce, params->dir);
+               BLI_cleanup_dir(G.main->name, params->dir);
                file_change_dir(C, 1);
 
                WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL);
@@ -544,7 +545,7 @@ void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile, char *filepath)
        BLI_join_dirfile(filepath, sfile->params->dir, sfile->params->file);
        if(RNA_struct_find_property(op->ptr, "relative_path")) {
                if(RNA_boolean_get(op->ptr, "relative_path")) {
-                       BLI_path_rel(filepath, G.sce);
+                       BLI_path_rel(filepath, G.main->name);
                }
        }
 
@@ -680,7 +681,7 @@ int file_exec(bContext *C, wmOperator *exec_op)
                file_sfile_to_operator(op, sfile, filepath);
 
                fsmenu_insert_entry(fsmenu_get(), FS_CATEGORY_RECENT, sfile->params->dir,0, 1);
-               BLI_make_file_string(G.sce, filepath, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE);
+               BLI_make_file_string(G.main->name, filepath, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE);
                fsmenu_write_file(fsmenu_get(), filepath);
                WM_event_fileselect_event(C, op, EVT_FILESELECT_EXEC);
 
@@ -711,7 +712,7 @@ int file_parent_exec(bContext *C, wmOperator *UNUSED(unused))
        if(sfile->params) {
                if (BLI_has_parent(sfile->params->dir)) {
                        BLI_parent_dir(sfile->params->dir);
-                       BLI_cleanup_dir(G.sce, sfile->params->dir);
+                       BLI_cleanup_dir(G.main->name, sfile->params->dir);
                        file_change_dir(C, 0);
                        WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL);
                }
@@ -1010,7 +1011,7 @@ int file_directory_exec(bContext *C, wmOperator *UNUSED(unused))
                if (sfile->params->dir[0] == '\0')
                        get_default_root(sfile->params->dir);
 #endif
-               BLI_cleanup_dir(G.sce, sfile->params->dir);
+               BLI_cleanup_dir(G.main->name, sfile->params->dir);
                BLI_add_slash(sfile->params->dir);
                file_change_dir(C, 1);
 
@@ -1240,7 +1241,7 @@ int file_delete_exec(bContext *C, wmOperator *UNUSED(op))
        
        
        file = filelist_file(sfile->files, sfile->params->active_file);
-       BLI_make_file_string(G.sce, str, sfile->params->dir, file->relname);
+       BLI_make_file_string(G.main->name, str, sfile->params->dir, file->relname);
        BLI_delete(str, 0, 0);  
        ED_fileselect_clear(C, sfile);
        WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL);
index 68a93d3906220c275cac916bfaf12e6b15f55595..43d5d54805d4c8263e168fc5f7cd61ccf5889f50 100644 (file)
@@ -730,7 +730,7 @@ static void filelist_read_dir(struct FileList* filelist)
 
        BLI_getwdN(wdir);        
 
-       BLI_cleanup_dir(G.sce, filelist->dir);
+       BLI_cleanup_dir(G.main->name, filelist->dir);
        filelist->numfiles = BLI_getdir(filelist->dir, &(filelist->filelist));
 
        if(!chdir(wdir)) {} /* fix warning about not checking return value */
@@ -747,7 +747,7 @@ static void filelist_read_main(struct FileList* filelist)
 static void filelist_read_library(struct FileList* filelist)
 {
        if (!filelist) return;
-       BLI_cleanup_dir(G.sce, filelist->dir);
+       BLI_cleanup_dir(G.main->name, filelist->dir);
        filelist_from_library(filelist);
        if(!filelist->libfiledata) {
                int num;
@@ -912,7 +912,7 @@ void filelist_from_library(struct FileList* filelist)
                return;
        }
        
-       BLI_strncpy(filename, G.sce, sizeof(filename)); // G.sce = last file loaded, for UI
+       BLI_strncpy(filename, G.main->name, sizeof(filename));
 
        /* there we go */
        /* for the time being only read filedata when libfiledata==0 */
@@ -979,7 +979,7 @@ void filelist_from_library(struct FileList* filelist)
 
        filelist_sort(filelist, FILE_SORT_ALPHA);
 
-       BLI_strncpy(G.sce, filename, sizeof(filename)); // prevent G.sce to change
+       BLI_strncpy(G.main->name, filename, sizeof(filename));  // prevent G.main->name to change
 
        filelist->filter = 0;
        filelist_filter(filelist);
index b36cfe66a3656eebb1cc6e3642b52620591cdbb3..8ad3ef08e850695518b28e1bba622a4ecf22c7be 100644 (file)
@@ -64,6 +64,7 @@
 
 #include "BKE_context.h"
 #include "BKE_global.h"
+#include "BKE_main.h"
 
 #include "BLF_api.h"
 
@@ -104,7 +105,7 @@ short ED_fileselect_set_params(SpaceFile *sfile)
        if (!sfile->params) {
                sfile->params= MEM_callocN(sizeof(FileSelectParams), "fileselparams");
                /* set path to most recently opened .blend */
-               BLI_split_dirfile(G.sce, sfile->params->dir, sfile->params->file);
+               BLI_split_dirfile(G.main->name, sfile->params->dir, sfile->params->file);
                sfile->params->filter_glob[0] = '\0';
        }
 
@@ -142,8 +143,8 @@ short ED_fileselect_set_params(SpaceFile *sfile)
                }
 
                if(params->dir[0]) {
-                       BLI_cleanup_dir(G.sce, params->dir);
-                       BLI_path_abs(params->dir, G.sce);
+                       BLI_cleanup_dir(G.main->name, params->dir);
+                       BLI_path_abs(params->dir, G.main->name);
                }
 
                params->filter = 0;
index f5ce5a818d771fa642f05dfe2efdaafe84746cac..750cf98727abc6c198d4df73e59089598c44673b 100644 (file)
@@ -41,6 +41,7 @@
 
 #include "BKE_context.h"
 #include "BKE_global.h"
+#include "BKE_main.h"
 #include "BKE_image.h"
 
 #include "RE_pipeline.h"
@@ -75,7 +76,7 @@ static void save_rendered_image_cb_real(char *name, int confirm)
                        BKE_add_image_extension(name, scene->r.imtype);
 
        strcpy(str, name);
-       BLI_path_abs(str, G.sce);
+       BLI_path_abs(str, G.main->name);
 
        if (confirm)
                overwrite = saveover(str);
@@ -218,7 +219,7 @@ void BIF_save_rendered_image_fs(Scene *scene)
                char dir[FILE_MAXDIR * 2], str[FILE_MAXFILE * 2];
                
                if(G.ima[0]==0) {
-                       strcpy(dir, G.sce);
+                       strcpy(dir, G.main->name);
                        BLI_splitdirstring(dir, str);
                        strcpy(G.ima, dir);
                }
index a44258351cef4e36237cbbe1ef781499273fb0b0..429ba64ed0fe05222395c05997766ed7fe777eaf 100644 (file)
@@ -133,7 +133,7 @@ static int space_image_file_exists_poll(bContext *C)
                ibuf= ED_space_image_acquire_buffer(sima, &lock);
                if(ibuf) {
                        BLI_strncpy(name, ibuf->name, FILE_MAX);
-                       BLI_path_abs(name, G.sce);
+                       BLI_path_abs(name, G.main->name);
                        poll= (BLI_exists(name) && BLI_is_writable(name));
                }
                ED_space_image_release_buffer(sima, lock);
@@ -856,7 +856,7 @@ static void save_image_doit(bContext *C, SpaceImage *sima, Scene *scene, wmOpera
                int relative= (RNA_struct_find_property(op->ptr, "relative_path") && RNA_boolean_get(op->ptr, "relative_path"));
                int save_copy= (RNA_struct_find_property(op->ptr, "copy") && RNA_boolean_get(op->ptr, "copy"));
 
-               BLI_path_abs(path, G.sce);
+               BLI_path_abs(path, G.main->name);
                
                if(scene->r.scemode & R_EXTENSION)  {
                        BKE_add_image_extension(path, sima->imtypenr);
@@ -876,7 +876,7 @@ static void save_image_doit(bContext *C, SpaceImage *sima, Scene *scene, wmOpera
                                RE_WriteRenderResult(rr, path, scene->r.quality);
 
                                if(relative)
-                                       BLI_path_rel(path, G.sce); /* only after saving */
+                                       BLI_path_rel(path, G.main->name); /* only after saving */
 
                                if(!save_copy) {
                                        if(do_newpath) {
@@ -896,7 +896,7 @@ static void save_image_doit(bContext *C, SpaceImage *sima, Scene *scene, wmOpera
                else if (BKE_write_ibuf(scene, ibuf, path, sima->imtypenr, scene->r.subimtype, scene->r.quality)) {
 
                        if(relative)
-                               BLI_path_rel(path, G.sce); /* only after saving */
+                               BLI_path_rel(path, G.main->name); /* only after saving */
 
                        if(!save_copy) {
                                if(do_newpath) {
@@ -1071,7 +1071,7 @@ static int save_exec(bContext *C, wmOperator *op)
        if(name[0]==0)
                BLI_strncpy(name, G.ima, FILE_MAX);
        else
-               BLI_path_abs(name, G.sce);
+               BLI_path_abs(name, G.main->name);
        
        if(BLI_exists(name) && BLI_is_writable(name)) {
                rr= BKE_image_acquire_renderresult(scene, ima);
@@ -1157,7 +1157,7 @@ static int save_sequence_exec(bContext *C, wmOperator *op)
                        char name[FILE_MAX];
                        BLI_strncpy(name, ibuf->name, sizeof(name));
                        
-                       BLI_path_abs(name, G.sce);
+                       BLI_path_abs(name, G.main->name);
 
                        if(0 == IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat)) {
                                BKE_reportf(op->reports, RPT_ERROR, "Could not write image %s.", name);
index c87b25877b40ecc718f4019c8f1cb8b32b6074ab..aeb32cda6bdd0a28d45aa6745cc5855b6359f567 100644 (file)
@@ -191,7 +191,7 @@ static int make_paths_relative_exec(bContext *UNUSED(C), wmOperator *op)
                return OPERATOR_CANCELLED;
        }
 
-       makeFilesRelative(G.sce, op->reports);
+       makeFilesRelative(G.main->name, op->reports);
 
        return OPERATOR_FINISHED;
 }
@@ -218,7 +218,7 @@ static int make_paths_absolute_exec(bContext *UNUSED(C), wmOperator *op)
                return OPERATOR_CANCELLED;
        }
 
-       makeFilesAbsolute(G.sce, op->reports);
+       makeFilesAbsolute(G.main->name, op->reports);
        return OPERATOR_FINISHED;
 }
 
@@ -244,7 +244,7 @@ static int report_missing_files_exec(bContext *UNUSED(C), wmOperator *op)
        txtname[0] = '\0';
        
        /* run the missing file check */
-       checkMissingFiles(G.sce, op->reports);
+       checkMissingFiles(G.main->name, op->reports);
        
        return OPERATOR_FINISHED;
 }
@@ -269,7 +269,7 @@ static int find_missing_files_exec(bContext *UNUSED(C), wmOperator *op)
        char *path;
        
        path= RNA_string_get_alloc(op->ptr, "filepath", NULL, 0);
-       findMissingFiles(path, G.sce);
+       findMissingFiles(path, G.main->name);
        MEM_freeN(path);
 
        return OPERATOR_FINISHED;
index 6040b755e302209a4804656e9cb00a4278d909eb..1f0725c5458c73cc51e08423b52aadc2ddfda157 100644 (file)
@@ -5035,7 +5035,7 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
                        if (te->idcode == ID_LI) {
                                char expanded[FILE_MAXDIR + FILE_MAXFILE];
                                BLI_strncpy(expanded, ((Library *)tselem->id)->name, FILE_MAXDIR + FILE_MAXFILE);
-                               BLI_path_abs(expanded, G.sce);
+                               BLI_path_abs(expanded, G.main->name);
                                if (!BLI_exists(expanded)) {
                                        error("This path does not exist, correct this before saving");
                                }
index b9db18f7850db96d347b01292ed0e63be8d0be13..5f0693dc43cd55193461d91ddcd7dce26677054b 100644 (file)
@@ -101,7 +101,7 @@ static void sequencer_generic_invoke_path__internal(bContext *C, wmOperator *op,
                if(last_seq && last_seq->strip && SEQ_HAS_PATH(last_seq)) {
                        char path[sizeof(last_seq->strip->dir)];
                        BLI_strncpy(path, last_seq->strip->dir, sizeof(path));
-                       BLI_path_abs(path, G.sce);
+                       BLI_path_abs(path, G.main->name);
                        RNA_string_set(op->ptr, identifier, path);
                }
        }
@@ -152,7 +152,7 @@ static void seq_load_operator_info(SeqLoadInfo *seq_load, wmOperator *op)
        }
 
        if((is_file != -1) && relative)
-               BLI_path_rel(seq_load->path, G.sce);
+               BLI_path_rel(seq_load->path, G.main->name);
 
        
        if (RNA_struct_find_property(op->ptr, "frame_end")) {
index bd53615fedacc24623d8e2c7be338179b9b2bc57..35f27953633191ba70ebb53d3d7b9f6ed9748be4 100644 (file)
@@ -992,7 +992,7 @@ void touch_seq_files(Scene *scene)
                if(seq->flag & SELECT) {
                        if(seq->type==SEQ_MOVIE) {
                                if(seq->strip && seq->strip->stripdata) {
-                                       BLI_make_file_string(G.sce, str, seq->strip->dir, seq->strip->stripdata->name);
+                                       BLI_make_file_string(G.main->name, str, seq->strip->dir, seq->strip->stripdata->name);
                                        BLI_touch(seq->name);
                                }
                        }
index 90fab7b2902191f37f14a12a56237897f962417f..8d4f3f87f669178ad6fad54d14d915c917b8cdf3 100644 (file)
@@ -221,7 +221,7 @@ static int open_exec(bContext *C, wmOperator *op)
 
        RNA_string_get(op->ptr, "filepath", str);
 
-       text= add_text(str, G.sce);
+       text= add_text(str, G.main->name);
 
        if(!text) {
                if(op->customdata) MEM_freeN(op->customdata);
@@ -266,7 +266,7 @@ static int open_exec(bContext *C, wmOperator *op)
 static int open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
 {
        Text *text= CTX_data_edit_text(C);
-       char *path= (text && text->name)? text->name: G.sce;
+       char *path= (text && text->name)? text->name: G.main->name;
 
        if(RNA_property_is_set(op->ptr, "filepath"))
                return open_exec(C, op);
@@ -438,7 +438,7 @@ static void txt_write_file(Text *text, ReportList *reports)
        char file[FILE_MAXDIR+FILE_MAXFILE];
        
        BLI_strncpy(file, text->name, FILE_MAXDIR+FILE_MAXFILE);
-       BLI_path_abs(file, G.sce);
+       BLI_path_abs(file, G.main->name);
        
        fp= fopen(file, "w");
        if(fp==NULL) {
@@ -524,7 +524,7 @@ static int save_as_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
        else if(text->flags & TXT_ISMEM)
                str= text->id.name+2;
        else
-               str= G.sce;
+               str= G.main->name;
        
        RNA_string_set(op->ptr, "filepath", str);
        WM_event_add_fileselect(C, op); 
@@ -2860,7 +2860,7 @@ int text_file_modified(Text *text)
                return 0;
 
        BLI_strncpy(file, text->name, FILE_MAXDIR+FILE_MAXFILE);
-       BLI_path_abs(file, G.sce);
+       BLI_path_abs(file, G.main->name);
 
        if(!BLI_exists(file))
                return 2;
@@ -2888,7 +2888,7 @@ static void text_ignore_modified(Text *text)
        if(!text || !text->name) return;
 
        BLI_strncpy(file, text->name, FILE_MAXDIR+FILE_MAXFILE);
-       BLI_path_abs(file, G.sce);
+       BLI_path_abs(file, G.main->name);
 
        if(!BLI_exists(file)) return;
 
index 70438ae3d8c563ff3404d24402b9866211cc2124..74d6110127321c4afd7a6902541ef87fb45a2fee 100644 (file)
@@ -41,7 +41,7 @@
 #include "BKE_packedFile.h"
 #include "BKE_main.h"
 #include "BKE_utildefines.h"
-#include "BKE_global.h" /* grr: G.sce */
+#include "BKE_global.h" /* grr: G.main->name */
 
 #include "IMB_imbuf.h"
 
@@ -90,7 +90,7 @@ static void rna_Image_save(Image *image, ReportList *reports)
        if(ibuf) {
                char filename[FILE_MAXDIR + FILE_MAXFILE];
                BLI_strncpy(filename, image->name, sizeof(filename));
-               BLI_path_abs(filename, G.sce);
+               BLI_path_abs(filename, G.main->name);
 
                if(image->packedfile) {
                        if (writePackedFile(reports, image->name, image->packedfile, 0) != RET_OK) {
index 176a52251e77e78b82ba3e31a1d71e9780356f66..fb3eb74a919a301f2c80532246efbb4a09414c86 100644 (file)
 #include "BLI_blenlib.h"
 #include "BLI_math.h"
 
+#include "BKE_main.h"
 #include "BKE_cdderivedmesh.h"
 #include "BKE_mesh.h"
 #include "BKE_utildefines.h"
-#include "BKE_global.h" /* G.sce only */
+#include "BKE_global.h" /* G.main->name only */
 
 #include "MOD_modifiertypes.h"
 
@@ -482,7 +483,7 @@ DerivedMesh *fluidsim_read_cache(DerivedMesh *orgdm, FluidsimModifierData *fluid
                strcat(targetDir,"fluidsurface_final_####");
        }
 
-       BLI_path_abs(targetDir, G.sce);
+       BLI_path_abs(targetDir, G.main->name);
        BLI_path_frame(targetDir, curFrame, 0); // fixed #frame-no
 
        strcpy(targetFile,targetDir);
index 568cef0f67610076b3b7cdaf39651e7a62bfa2e5..6d42c7945836bc91bbbfc11ba7ab2107aebff9b0 100644 (file)
@@ -33,7 +33,7 @@
 #include "BKE_utildefines.h" /* UNUSED */      
 #include "BKE_text.h" /* txt_to_buf */ 
 #include "BKE_main.h"
-#include "BKE_global.h" /* grr, only for G.sce */
+#include "BKE_global.h" /* grr, only for G.main->name */
 #include "BLI_listbase.h"
 #include "BLI_path_util.h"
 #include "BLI_string.h"
@@ -62,7 +62,7 @@ void bpy_import_main_set(struct Main *maggie)
 /* returns a dummy filename for a textblock so we can tell what file a text block comes from */
 void bpy_text_filename_get(char *fn, Text *text)
 {
-       sprintf(fn, "%s/%s", text->id.lib ? text->id.lib->filepath : G.sce, text->id.name+2);
+       sprintf(fn, "%s/%s", text->id.lib ? text->id.lib->filepath : G.main->name, text->id.name+2);
        
        /* XXX, this is a bug in python's Py_CompileString()!
         the string encoding should not be required to be utf-8
index 9664a5b16f8d5929883a5823d082e3b2df61a4a1..de16fba9a30cead674344bf09493df4b88e67011 100644 (file)
@@ -494,7 +494,7 @@ void filepath_qt(char *string, RenderData *rd) {
        if (string==0) return;
 
        strcpy(string, rd->pic);
-       BLI_path_abs(string, G.sce);
+       BLI_path_abs(string, G.main->name);
 
        BLI_make_existing_file(string);
 
index a2f08d96251f4af7e86fa890ba8044a2d2294c37..7230e0b39096e6ea442c6a2c2475b5ed962f6abc 100644 (file)
@@ -452,7 +452,7 @@ static void render_unique_exr_name(Render *re, char *str, int sample)
 {
        char di[FILE_MAX], name[FILE_MAXFILE+MAX_ID_NAME+100], fi[FILE_MAXFILE];
        
-       BLI_strncpy(di, G.sce, FILE_MAX);
+       BLI_strncpy(di, G.main->name, FILE_MAX);
        BLI_splitdirstring(di, fi);
        
        if(sample==0)
@@ -2032,7 +2032,7 @@ static void load_backbuffer(Render *re)
                char name[256];
                
                strcpy(name, re->r.backbuf);
-               BLI_path_abs(name, G.sce);
+               BLI_path_abs(name, G.main->name);
                BLI_path_frame(name, re->r.cfra, 0);
                
                if(re->backbuf) {
index 66d2a1efdeaaa7a85592db602a31190dfbc727b6..00a686c0d7431ff529842404f7e28db130e30e8f 100644 (file)
@@ -335,13 +335,10 @@ void WM_read_file(bContext *C, char *name, ReportList *reports)
 /* called on startup,  (context entirely filled with NULLs) */
 /* or called for 'New File' */
 /* op can be NULL */
-/* note: G.sce is used to store the last saved path so backup and restore after loading
- * G.main->name is similar to G.sce but when loading from memory set the name to startup.blend 
- * ...this could be changed but seems better then setting to "" */
 int WM_read_homefile(bContext *C, wmOperator *op)
 {
        ListBase wmbase;
-       char tstr[FILE_MAXDIR+FILE_MAXFILE], scestr[FILE_MAXDIR];
+       char tstr[FILE_MAXDIR+FILE_MAXFILE];
        int from_memory= op && strcmp(op->type->idname, "WM_OT_read_factory_settings")==0;
        int success;
        
@@ -351,7 +348,7 @@ int WM_read_homefile(bContext *C, wmOperator *op)
        if (!from_memory) {
                char *cfgdir = BLI_get_folder(BLENDER_USER_CONFIG, NULL);
                if (cfgdir) {
-                       BLI_make_file_string(G.sce, tstr, cfgdir, BLENDER_STARTUP_FILE);
+                       BLI_make_file_string(G.main->name, tstr, cfgdir, BLENDER_STARTUP_FILE);
                } else {
                        tstr[0] = '\0';
                        from_memory = 1;
@@ -360,7 +357,6 @@ int WM_read_homefile(bContext *C, wmOperator *op)
                        }
                }
        }
-       strcpy(scestr, G.sce);  /* temporary store */
        
        /* prevent loading no UI */
        G.fileflags &= ~G_FILE_NO_UI;
@@ -383,7 +379,6 @@ int WM_read_homefile(bContext *C, wmOperator *op)
        wm_window_match_do(C, &wmbase); 
        WM_check(C); /* opens window(s), checks keymaps */
 
-       strcpy(G.sce, scestr); /* restore */
        G.main->name[0]= '\0';
 
        wm_init_userdef(C);
@@ -440,9 +435,6 @@ void read_history(void)
        for (l= lines, num= 0; l && (num<U.recent_files); l= l->next) {
                line = l->link;
                if (line[0] && BLI_exists(line)) {
-                       if (num==0) 
-                               strcpy(G.sce, line); /* note: this seems highly dodgy since the file isnt actually read. please explain. - campbell */
-                       
                        recent = (RecentFile*)MEM_mallocN(sizeof(RecentFile),"RecentFile");
                        BLI_addtail(&(G.recent_files), recent);
                        recent->filepath = (char*)MEM_mallocN(sizeof(char)*(strlen(line)+1), "name of file");
@@ -468,14 +460,14 @@ static void write_history(void)
 
        recent = G.recent_files.first;
        /* refresh recent-files.txt of recent opened files, when current file was changed */
-       if(!(recent) || (strcmp(recent->filepath, G.sce)!=0)) {
+       if(!(recent) || (strcmp(recent->filepath, G.main->name)!=0)) {
                fp= fopen(name, "w");
                if (fp) {
                        /* add current file to the beginning of list */
                        recent = (RecentFile*)MEM_mallocN(sizeof(RecentFile),"RecentFile");
-                       recent->filepath = (char*)MEM_mallocN(sizeof(char)*(strlen(G.sce)+1), "name of file");
+                       recent->filepath = (char*)MEM_mallocN(sizeof(char)*(strlen(G.main->name)+1), "name of file");
                        recent->filepath[0] = '\0';
-                       strcpy(recent->filepath, G.sce);
+                       strcpy(recent->filepath, G.main->name);
                        BLI_addhead(&(G.recent_files), recent);
                        /* write current file to recent-files.txt */
                        fprintf(fp, "%s\n", recent->filepath);
@@ -484,7 +476,7 @@ static void write_history(void)
                        /* write rest of recent opened files to recent-files.txt */
                        while((i<U.recent_files) && (recent)){
                                /* this prevents to have duplicities in list */
-                               if (strcmp(recent->filepath, G.sce)!=0) {
+                               if (strcmp(recent->filepath, G.main->name)!=0) {
                                        fprintf(fp, "%s\n", recent->filepath);
                                        recent = recent->next;
                                }
@@ -572,7 +564,7 @@ static ImBuf *blend_file_thumb(Scene *scene, int **thumb_pt)
 int write_crash_blend(void)
 {
        char path[FILE_MAX];
-       BLI_strncpy(path, G.sce, sizeof(path));
+       BLI_strncpy(path, G.main->name, sizeof(path));
        BLI_replace_extension(path, sizeof(path), "_crash.blend");
        if(BLO_write_file(G.main, path, G.fileflags, NULL, NULL)) {
                printf("written: %s\n", path);
@@ -634,7 +626,6 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re
 
        if (BLO_write_file(CTX_data_main(C), di, fileflags, reports, thumb)) {
                if(!copy) {
-                       strcpy(G.sce, di);
                        G.relbase_valid = 1;
                        strcpy(G.main->name, di);       /* is guaranteed current file */
        
index 983361f01ff9b9888a9b8fb8e92b1a701d74b147..b319058ce5cd2cefdf51a8e8a665ab7bb40d751d 100644 (file)
@@ -167,10 +167,10 @@ void WM_init(bContext *C, int argc, char **argv)
        
        read_history();
 
-       if(G.sce[0] == 0)
-               BLI_make_file_string("/", G.sce, BLI_getDefaultDocumentFolder(), "untitled.blend");
+       if(G.main->name[0] == 0)
+               BLI_make_file_string("/", G.main->name, BLI_getDefaultDocumentFolder(), "untitled.blend");
 
-       BLI_strncpy(G.lib, G.sce, FILE_MAX);
+       BLI_strncpy(G.lib, G.main->name, FILE_MAX);
 
 }
 
index ef3c8fb789e5d68c689e8575b76cfdbecb93b0e0..de08c209d0621416369d0ed6757c0075f49d9384 100644 (file)
@@ -1440,7 +1440,7 @@ static void open_set_use_scripts(wmOperator *op)
 
 static int wm_open_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
 {
-       RNA_string_set(op->ptr, "filepath", G.sce);
+       RNA_string_set(op->ptr, "filepath", G.main->name);
        open_set_load_ui(op);
        open_set_use_scripts(op);
 
@@ -1773,7 +1773,7 @@ static int wm_save_as_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *UNUS
 
        save_set_compress(op);
        
-       BLI_strncpy(name, G.sce, FILE_MAX);
+       BLI_strncpy(name, G.main->name, FILE_MAX);
        untitled(name);
        RNA_string_set(op->ptr, "filepath", name);
        
@@ -1794,7 +1794,7 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op)
        if(RNA_property_is_set(op->ptr, "filepath"))
                RNA_string_get(op->ptr, "filepath", path);
        else {
-               BLI_strncpy(path, G.sce, FILE_MAX);
+               BLI_strncpy(path, G.main->name, FILE_MAX);
                untitled(path);
        }
 
@@ -1859,7 +1859,7 @@ static int wm_save_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(
 
        save_set_compress(op);
        
-       BLI_strncpy(name, G.sce, FILE_MAX);
+       BLI_strncpy(name, G.main->name, FILE_MAX);
        untitled(name);
        RNA_string_set(op->ptr, "filepath", name);
        
@@ -1905,7 +1905,7 @@ static int wm_collada_export_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {      
        if(!RNA_property_is_set(op->ptr, "filepath")) {
                char filepath[FILE_MAX];
-               BLI_strncpy(filepath, G.sce, sizeof(filepath));
+               BLI_strncpy(filepath, G.main->name, sizeof(filepath));
                BLI_replace_extension(filepath, sizeof(filepath), ".dae");
                RNA_string_set(op->ptr, "filepath", filepath);
        }
index fbc77d0d06da4261f9481e27b87519ef2920e49b..69a29092058abb0bc30e0e367bcf40aa67d35c15 100644 (file)
@@ -45,6 +45,7 @@
 #include "BKE_blender.h"
 #include "BKE_context.h"
 #include "BKE_global.h"
+#include "BKE_main.h"
 #include "BKE_utildefines.h"
 
 #include "BIF_gl.h"
@@ -260,17 +261,15 @@ void wm_window_title(wmWindowManager *wm, wmWindow *win)
        else {
                
                /* this is set to 1 if you don't have startup.blend open */
-               if(G.save_over) {
-                       char *str= MEM_mallocN(strlen(G.sce) + 16, "title");
+               if(G.save_over && G.main->name[0]) {
+                       char str[sizeof(G.main->name) + 12];
                        
                        if(wm->file_saved)
-                               sprintf(str, "Blender [%s]", G.sce);
+                               sprintf(str, "Blender [%s]", G.main->name);
                        else
-                               sprintf(str, "Blender* [%s]", G.sce);
+                               sprintf(str, "Blender* [%s]", G.main->name);
                        
                        GHOST_SetTitle(win->ghostwin, str);
-                       
-                       MEM_freeN(str);
                }
                else
                        GHOST_SetTitle(win->ghostwin, "Blender");
index d65993581b53f9a335724ee4f359f8cea9499b86..858a5964a52caeb1bfc9d965f9aad22f576537cd 100644 (file)
@@ -141,10 +141,10 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
        BlendFileData *bfd= NULL;
 
        BLI_strncpy(pathname, blenderdata->name, sizeof(pathname));
-       BLI_strncpy(oldsce, G.sce, sizeof(oldsce));
+       BLI_strncpy(oldsce, G.main->name, sizeof(oldsce));
 #ifndef DISABLE_PYTHON
        resetGamePythonPath(); // need this so running a second time wont use an old blendfiles path
-       setGamePythonPath(G.sce);
+       setGamePythonPath(G.main->name);
 
        // Acquire Python's GIL (global interpreter lock)
        // so we can safely run Python code and API calls
@@ -309,10 +309,10 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
                                startscenename = bfd->curscene->id.name + 2;
 
                                if(blenderdata) {
-                                       BLI_strncpy(G.sce, blenderdata->name, sizeof(G.sce));
+                                       BLI_strncpy(G.main->name, blenderdata->name, sizeof(G.main->name));
                                        BLI_strncpy(pathname, blenderdata->name, sizeof(pathname));
 #ifndef DISABLE_PYTHON
-                                       setGamePythonPath(G.sce);
+                                       setGamePythonPath(G.main->name);
 #endif
                                }
                        }
@@ -573,7 +573,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
 
        if (bfd) BLO_blendfiledata_free(bfd);
 
-       BLI_strncpy(G.sce, oldsce, sizeof(G.sce));
+       BLI_strncpy(G.main->name, oldsce, sizeof(G.main->name));
 
 #ifndef DISABLE_PYTHON
        Py_DECREF(pyGlobalDict);
index e1cd1c6d488b938d92ca0fd6c8b9ef71b3ec4dce..5e1e213c5701108c8ec596896908cf16d8e56d61 100644 (file)
@@ -67,6 +67,7 @@ extern "C" {
 #include "DNA_windowmanager_types.h"
 
 #include "BKE_global.h"
+#include "BKE_main.h"
 #include "BKE_bmfont.h"
 #include "BKE_image.h"
 
@@ -247,7 +248,7 @@ void BL_MakeScreenShot(ScrArea *curarea, const char* filename)
        dumprect= screenshot(curarea, &dumpsx, &dumpsy);
        if(dumprect) {
                ImBuf *ibuf;
-               BLI_path_abs(path, G.sce);
+               BLI_path_abs(path, G.main->name);
                /* BKE_add_image_extension() checks for if extension was already set */
                BKE_add_image_extension(path, R_PNG); /* scene->r.imtype */
                ibuf= IMB_allocImBuf(dumpsx, dumpsy, 24, 0);
index 9c0b5a24aeb360971e6a10b0a9e3c118f71fcd9a..e9dfd2a6e26dd9174fbaf75930e270240e0cfad6 100644 (file)
@@ -821,8 +821,8 @@ int main(int argc, char** argv)
                                                app.SetGameEngineData(maggie, scene, argc, argv); /* this argc cant be argc_py_clamped, since python uses it */
                                                
                                                BLI_strncpy(pathname, maggie->name, sizeof(pathname));
-                                               BLI_strncpy(G.sce, maggie->name, sizeof(G.sce));
-                                               setGamePythonPath(G.sce);
+                                               BLI_strncpy(G.main->name, maggie->name, sizeof(G.main->name));
+                                               setGamePythonPath(G.main->name);
 
                                                if (firstTimeRunning)
                                                {