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>2011-01-07 09:50:29 +0300
committerCampbell Barton <ideasman42@gmail.com>2011-01-07 09:50:29 +0300
commita13267463425d22f69d3d1d313df921e6c1238f9 (patch)
tree1cfe48535b793f872bf9e29a7c9a0b2f55bdae4b /source/blender/windowmanager
parent0db684be3cc0326d829ec3b946ca005891d720f8 (diff)
patch [#25490] Fix for [#22096] Blender tries to open non-blend file
from Alexander Kuznetsov (alexk) with edits. From the report: Blender assumed that all files are .blend as retval = 0; Now retval is initialized as file cannot be open (-1) for gzopen fail and directory case retval = -2; is defined for not supported formats This must be assigned before #ifdef WITH_PYTHON because this part can be missing Finally retval = 0; if it is a .blend file --- also made other edits. - exotic.c's blend header checking was sloppy, didn't check data was actually read, only checked first 4 bytes and had a check for "blend.gz" extension which is unnecessary. - use defines to help readability for BKE_read_exotic & BKE_read_file return values. - no need to check for a NULL pointer before calling BKE_reportf(). (will just print to the console) - print better reports when the file fails to load.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r--source/blender/windowmanager/intern/wm_files.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index e7165598e38..22b10c8c618 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -276,7 +276,7 @@ void WM_read_file(bContext *C, const char *name, ReportList *reports)
retval= BKE_read_exotic(CTX_data_scene(C), name);
/* we didn't succeed, now try to read Blender file */
- if (retval== 0) {
+ if (retval == BKE_READ_EXOTIC_OK_BLEND) {
int G_f= G.f;
ListBase wmbase;
@@ -298,9 +298,9 @@ void WM_read_file(bContext *C, const char *name, ReportList *reports)
// XXX mainwindow_set_filename_to_title(G.main->name);
- if(retval==2) wm_init_userdef(C); // in case a userdef is read from regular .blend
+ if(retval == BKE_READ_FILE_OK_USERPREFS) wm_init_userdef(C); // in case a userdef is read from regular .blend
- if (retval!=0) {
+ if (retval != BKE_READ_FILE_FAIL) {
G.relbase_valid = 1;
if(!G.background) /* assume automated tasks with background, dont write recent file list */
write_history();
@@ -327,13 +327,22 @@ void WM_read_file(bContext *C, const char *name, ReportList *reports)
BKE_write_undo(C, "original"); /* save current state */
}
- else if(retval==1)
+ else if(retval == BKE_READ_EXOTIC_OK_OTHER)
BKE_write_undo(C, "Import file");
- else if(retval == -1) {
- if(reports)
- BKE_reportf(reports, RPT_ERROR, "Can't read file: \"%s\", %s.", name, errno ? strerror(errno) : "Incompatible file format");
+ else if(retval == BKE_READ_EXOTIC_FAIL_OPEN) {
+ BKE_reportf(reports, RPT_ERROR, "Can't read file: \"%s\", %s.", name, errno ? strerror(errno) : "Unable to open the file");
}
-
+ else if(retval == BKE_READ_EXOTIC_FAIL_FORMAT) {
+ BKE_reportf(reports, RPT_ERROR, "File format is not supported in file: \"%s\".", name);
+ }
+ else if(retval == BKE_READ_EXOTIC_FAIL_PATH) {
+ BKE_reportf(reports, RPT_ERROR, "File path invalid: \"%s\".", name);
+ }
+ else {
+ BKE_reportf(reports, RPT_ERROR, "Unknown error loading: \"%s\".", name);
+ BKE_assert(!"invalid 'retval'");
+ }
+
WM_cursor_wait(0);
}
@@ -372,7 +381,7 @@ int WM_read_homefile(bContext *C, wmOperator *op)
wm_window_match_init(C, &wmbase);
if (!from_memory && BLI_exists(tstr)) {
- success = BKE_read_file(C, tstr, NULL);
+ success = (BKE_read_file(C, tstr, NULL) != BKE_READ_FILE_FAIL);
if(U.themes.first==NULL) {
printf("\nError: No valid startup.blend, fall back to built-in default.\n\n");