forked from bartvdbraak/blender
Python Bugfix
A new file could have its Blender.Get("filename") return "<memory>" after undo'ing on an open file. Fix for own error with python sys.path, messed up game engine.
This commit is contained in:
parent
1892df0e68
commit
4c0b33ef80
@ -482,7 +482,7 @@ int BKE_read_file_from_memory(char* filebuf, int filelength, void *type_r)
|
|||||||
if (type_r)
|
if (type_r)
|
||||||
*((BlenFileType*)type_r)= bfd->type;
|
*((BlenFileType*)type_r)= bfd->type;
|
||||||
|
|
||||||
setup_app_data(bfd, "<memory>");
|
setup_app_data(bfd, "<memory2>");
|
||||||
} else {
|
} else {
|
||||||
error("Loading failed: %s", BLO_bre_as_string(bre));
|
error("Loading failed: %s", BLO_bre_as_string(bre));
|
||||||
}
|
}
|
||||||
@ -504,7 +504,7 @@ int BKE_read_file_from_memfile(MemFile *memfile)
|
|||||||
|
|
||||||
bfd= BLO_read_from_memfile(G.sce, memfile, &bre);
|
bfd= BLO_read_from_memfile(G.sce, memfile, &bre);
|
||||||
if (bfd) {
|
if (bfd) {
|
||||||
setup_app_data(bfd, "<memory>");
|
setup_app_data(bfd, "<memory1>");
|
||||||
} else {
|
} else {
|
||||||
error("Loading failed: %s", BLO_bre_as_string(bre));
|
error("Loading failed: %s", BLO_bre_as_string(bre));
|
||||||
}
|
}
|
||||||
|
@ -576,6 +576,8 @@ typedef struct Scene {
|
|||||||
#define R_FBUF 0x40000
|
#define R_FBUF 0x40000
|
||||||
/* threads obsolete... is there for old files, now use for autodetect threads */
|
/* threads obsolete... is there for old files, now use for autodetect threads */
|
||||||
#define R_THREADS 0x80000
|
#define R_THREADS 0x80000
|
||||||
|
/* Use the same flag for autothreads */
|
||||||
|
#define R_AUTO_THREADS 0x80000
|
||||||
|
|
||||||
#define R_SPEED 0x100000
|
#define R_SPEED 0x100000
|
||||||
#define R_SSS 0x200000
|
#define R_SSS 0x200000
|
||||||
|
@ -377,7 +377,7 @@ void init_syspath( int first_time )
|
|||||||
d = PyModule_GetDict( mod ); /* borrowed ref */
|
d = PyModule_GetDict( mod ); /* borrowed ref */
|
||||||
EXPP_dict_set_item_str( d, "executable", Py_BuildValue( "s", bprogname ) );
|
EXPP_dict_set_item_str( d, "executable", Py_BuildValue( "s", bprogname ) );
|
||||||
|
|
||||||
if (first_time) {
|
if (bpy_orig_syspath_List == NULL) {
|
||||||
/* backup the original sys.path to rebuild later */
|
/* backup the original sys.path to rebuild later */
|
||||||
PyObject *syspath = PyDict_GetItemString( d, "path" ); /* borrowed ref */
|
PyObject *syspath = PyDict_GetItemString( d, "path" ); /* borrowed ref */
|
||||||
if (bpy_orig_syspath_List) { /* This should never happen but just incase, be nice */
|
if (bpy_orig_syspath_List) { /* This should never happen but just incase, be nice */
|
||||||
@ -401,12 +401,12 @@ void BPY_rebuild_syspath( void )
|
|||||||
|
|
||||||
mod = PyImport_ImportModule( "sys" );
|
mod = PyImport_ImportModule( "sys" );
|
||||||
if (!mod) {
|
if (!mod) {
|
||||||
printf("error: could not import python sys module. some modules may not import.");
|
printf("error: could not import python sys module. some modules may not import.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bpy_orig_syspath_List) { /* should never happen */
|
if (!bpy_orig_syspath_List) { /* should never happen */
|
||||||
printf("error refershing python path");
|
printf("error refershing python path\n");
|
||||||
Py_DECREF(mod);
|
Py_DECREF(mod);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -341,10 +341,10 @@ static PyObject *Blender_Get( PyObject * self, PyObject * value )
|
|||||||
else if( StringEqual( str, "endframe" ) )
|
else if( StringEqual( str, "endframe" ) )
|
||||||
ret = PyInt_FromLong( G.scene->r.efra );
|
ret = PyInt_FromLong( G.scene->r.efra );
|
||||||
else if( StringEqual( str, "filename" ) ) {
|
else if( StringEqual( str, "filename" ) ) {
|
||||||
if ( strstr(G.main->name, ".B.blend") != 0)
|
if (!G.relbase_valid)
|
||||||
ret = PyString_FromString("");
|
ret = PyString_FromString("");
|
||||||
else
|
else
|
||||||
ret = PyString_FromString(G.main->name);
|
ret = PyString_FromString(G.sce);
|
||||||
}
|
}
|
||||||
else if( StringEqual( str, "homedir" ) ) {
|
else if( StringEqual( str, "homedir" ) ) {
|
||||||
char *hdir = bpy_gethome(0);
|
char *hdir = bpy_gethome(0);
|
||||||
|
@ -2089,7 +2089,7 @@ static int RenderData_setModeBit( BPy_RenderData* self, PyObject *value,
|
|||||||
|
|
||||||
#define MODE_MASK ( R_OSA | R_SHADOW | R_GAMMA | R_ENVMAP | R_EDGE | \
|
#define MODE_MASK ( R_OSA | R_SHADOW | R_GAMMA | R_ENVMAP | R_EDGE | \
|
||||||
R_FIELDS | R_FIELDSTILL | R_RADIO | R_BORDER | R_PANORAMA | R_CROP | \
|
R_FIELDS | R_FIELDSTILL | R_RADIO | R_BORDER | R_PANORAMA | R_CROP | \
|
||||||
R_ODDFIELD | R_MBLUR | R_RAYTRACE | R_THREADS )
|
R_ODDFIELD | R_MBLUR | R_RAYTRACE | R_AUTO_THREADS )
|
||||||
|
|
||||||
static PyObject *RenderData_getMode( BPy_RenderData *self )
|
static PyObject *RenderData_getMode( BPy_RenderData *self )
|
||||||
{
|
{
|
||||||
@ -2593,10 +2593,13 @@ static PyGetSetDef BPy_RenderData_getseters[] = {
|
|||||||
(getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
|
(getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
|
||||||
"Skip rendering existing image files",
|
"Skip rendering existing image files",
|
||||||
(void *)R_NO_OVERWRITE},
|
(void *)R_NO_OVERWRITE},
|
||||||
|
{"autoThreads",
|
||||||
|
(getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
|
||||||
|
"Use system number of processors",
|
||||||
|
(void *)R_AUTO_THREADS},
|
||||||
/* R_GAUSS unused */
|
/* R_GAUSS unused */
|
||||||
/* R_FBUF unused */
|
/* R_FBUF unused */
|
||||||
/* R_THREADS unused */
|
/* R_AUTO_THREADS unused */
|
||||||
{"threads",
|
{"threads",
|
||||||
(getter)RenderData_getThreads, (setter)RenderData_setThreads,
|
(getter)RenderData_getThreads, (setter)RenderData_setThreads,
|
||||||
"Number of threads used to render",
|
"Number of threads used to render",
|
||||||
@ -3718,7 +3721,7 @@ static PyObject *M_Render_ModesDict( void )
|
|||||||
PyConstant_Insert( d, "ODDFIELD", PyInt_FromLong( R_ODDFIELD ) );
|
PyConstant_Insert( d, "ODDFIELD", PyInt_FromLong( R_ODDFIELD ) );
|
||||||
PyConstant_Insert( d, "MBLUR", PyInt_FromLong( R_MBLUR ) );
|
PyConstant_Insert( d, "MBLUR", PyInt_FromLong( R_MBLUR ) );
|
||||||
PyConstant_Insert( d, "RAYTRACING", PyInt_FromLong( R_RAYTRACE ) );
|
PyConstant_Insert( d, "RAYTRACING", PyInt_FromLong( R_RAYTRACE ) );
|
||||||
PyConstant_Insert( d, "THREADS", PyInt_FromLong( R_THREADS ) );
|
PyConstant_Insert( d, "AUTOTHREADS", PyInt_FromLong( R_AUTO_THREADS ) );
|
||||||
}
|
}
|
||||||
return M;
|
return M;
|
||||||
}
|
}
|
||||||
|
@ -1108,7 +1108,7 @@ void RE_InitState(Render *re, Render *source, RenderData *rd, int winx, int winy
|
|||||||
/* we clip faces with a minimum of 2 pixel boundary outside of image border. see zbuf.c */
|
/* we clip faces with a minimum of 2 pixel boundary outside of image border. see zbuf.c */
|
||||||
re->clipcrop= 1.0f + 2.0f/(float)(re->winx>re->winy?re->winy:re->winx);
|
re->clipcrop= 1.0f + 2.0f/(float)(re->winx>re->winy?re->winy:re->winx);
|
||||||
|
|
||||||
if (rd->mode & R_THREADS || commandline_threads == 0) { /* Automatic threads */
|
if (rd->mode & R_AUTO_THREADS || commandline_threads == 0) { /* Automatic threads */
|
||||||
re->r.threads = BLI_system_thread_count();
|
re->r.threads = BLI_system_thread_count();
|
||||||
} else if(commandline_threads >= 1 && commandline_threads<=BLENDER_MAX_THREADS) {
|
} else if(commandline_threads >= 1 && commandline_threads<=BLENDER_MAX_THREADS) {
|
||||||
re->r.threads= commandline_threads;
|
re->r.threads= commandline_threads;
|
||||||
|
@ -2023,8 +2023,8 @@ static void render_panel_output(void)
|
|||||||
uiBlockEndAlign(block);
|
uiBlockEndAlign(block);
|
||||||
|
|
||||||
uiBlockBeginAlign(block);
|
uiBlockBeginAlign(block);
|
||||||
uiDefIconButBitI(block, TOG, R_THREADS, B_REDR, ICON_AUTO, 10, 63, 20, 20, &G.scene->r.mode, 0.0, 0.0, 0, 0, "Automatic threads from system");
|
uiDefIconButBitI(block, TOG, R_AUTO_THREADS, B_REDR, ICON_AUTO, 10, 63, 20, 20, &G.scene->r.mode, 0.0, 0.0, 0, 0, "Automatically set the threads to the number of processors on the system");
|
||||||
if (G.scene->r.mode & R_THREADS) {
|
if (G.scene->r.mode & R_AUTO_THREADS) {
|
||||||
char thread_str[16];
|
char thread_str[16];
|
||||||
sprintf(thread_str, " Threads: %d", BLI_system_thread_count());
|
sprintf(thread_str, " Threads: %d", BLI_system_thread_count());
|
||||||
uiDefBut(block, LABEL, 0, thread_str, 30, 63,80,20, 0, 0, 0, 0, 0, "");
|
uiDefBut(block, LABEL, 0, thread_str, 30, 63,80,20, 0, 0, 0, 0, 0, "");
|
||||||
|
@ -264,8 +264,6 @@ static Scene *preview_prepare_scene(RenderInfo *ri, int id_type, ID *id, int pr_
|
|||||||
|
|
||||||
sce= pr_main->scene.first;
|
sce= pr_main->scene.first;
|
||||||
if(sce) {
|
if(sce) {
|
||||||
|
|
||||||
// sce->r.mode |= G.scene->r.mode & R_THREADS;
|
|
||||||
/* this flag tells render to not execute depsgraph or ipos etc */
|
/* this flag tells render to not execute depsgraph or ipos etc */
|
||||||
sce->r.scemode |= R_PREVIEWBUTS;
|
sce->r.scemode |= R_PREVIEWBUTS;
|
||||||
/* set world always back, is used now */
|
/* set world always back, is used now */
|
||||||
|
Loading…
Reference in New Issue
Block a user