Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-10-18 10:41:16 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-10-18 10:41:16 +0400
commit4d37cf90b9d9d8ed2f0339c8ccd72481e29a4514 (patch)
tree8442faaffb762a79497a45d90f503ccedc4cd0b4 /source/blender/windowmanager
parentb3afc3618db09942f83d4a3ac62834e7b925d5d7 (diff)
remove G.sce, use G.main->name instead.
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.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r--source/blender/windowmanager/intern/wm_files.c23
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c6
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c10
-rw-r--r--source/blender/windowmanager/intern/wm_window.c11
4 files changed, 20 insertions, 30 deletions
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 66d2a1efdea..00a686c0d74 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -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 */
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index 983361f01ff..b319058ce5c 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -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);
}
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index ef3c8fb789e..de08c209d06 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -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);
}
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index fbc77d0d06d..69a29092058 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -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");