fix for own error when trying to fix python command line crash,

was calling screenmain() before executing the python script which meant it was never executed (therefore no crash :) )

Moved screenmain() back to the the end of main() and added a TESTBASELIB_BGMODE which checks for G.vd and uses the scene layer if its not there. Of course python should not be running stuff that uses G.vd :/

Also made python scripts stay attached to screens when LOAD UI is disabled. This means you can load a new blend file and the python console can stay open, has been tested for a while in the apricot branch.
This commit is contained in:
Campbell Barton 2008-04-27 11:37:57 +00:00
parent bc059cb8b2
commit db18b47be5
5 changed files with 11 additions and 8 deletions

@ -330,6 +330,7 @@ static void setup_app_data(BlendFileData *bfd, char *filename)
extern void lib_link_screen_restore(Main *, Scene *);
SWAP(ListBase, G.main->screen, bfd->main->screen);
SWAP(ListBase, G.main->script, bfd->main->script);
/* we re-use current screen */
curscreen= G.curscreen;

@ -246,7 +246,6 @@ static void image_free_buffers(Image *ima)
/* called by library too, do not free ima itself */
void free_image(Image *ima)
{
image_free_buffers(ima);
if (ima->packedfile) {
freePackedFile(ima->packedfile);
@ -257,7 +256,6 @@ void free_image(Image *ima)
if (ima->preview) {
BKE_previewimg_free(&ima->preview);
}
}
/* only image block itself */

@ -96,6 +96,10 @@
#define TESTBASE(base) ( ((base)->flag & SELECT) && ((base)->lay & G.vd->lay) && (((base)->object->restrictflag & OB_RESTRICT_VIEW)==0) )
#define TESTBASELIB(base) ( ((base)->flag & SELECT) && ((base)->lay & G.vd->lay) && ((base)->object->id.lib==0) && (((base)->object->restrictflag & OB_RESTRICT_VIEW)==0))
/* This is a TESTBASELIB that can work without a 3D view */
#define TESTBASELIB_BGMODE(base) ( ((base)->flag & SELECT) && ((base)->lay & (G.vd ? G.vd->lay : G.scene->lay)) && ((base)->object->id.lib==0) && (((base)->object->restrictflag & OB_RESTRICT_VIEW)==0))
#define BASE_SELECTABLE(base) ((base->lay & G.vd->lay) && (base->object->restrictflag & (OB_RESTRICT_SELECT|OB_RESTRICT_VIEW))==0)
#define FIRSTBASE G.scene->base.first
#define LASTBASE G.scene->base.last

@ -164,7 +164,7 @@ int join_mesh(void)
/* count & check */
base= FIRSTBASE;
while(base) {
if TESTBASELIB(base) {
if TESTBASELIB_BGMODE(base) { /* BGMODE since python can access */
if(base->object->type==OB_MESH) {
me= base->object->data;
totvert+= me->totvert;
@ -200,7 +200,7 @@ int join_mesh(void)
/* if needed add edges to other meshes */
for(base= FIRSTBASE; base; base= base->next) {
if TESTBASELIB(base) {
if TESTBASELIB_BGMODE(base) {
if(base->object->type==OB_MESH) {
me= base->object->data;
totedge += me->totedge;
@ -221,7 +221,7 @@ int join_mesh(void)
base= FIRSTBASE;
while(base) {
if TESTBASELIB(base) {
if TESTBASELIB_BGMODE(base) {
if(ob!=base->object && base->object->type==OB_MESH) {
me= base->object->data;
@ -288,7 +288,7 @@ int join_mesh(void)
base= FIRSTBASE;
while(base) {
nextb= base->next;
if TESTBASELIB(base) {
if TESTBASELIB_BGMODE(base) {
if(base->object->type==OB_MESH) {
me= base->object->data;

@ -263,8 +263,6 @@ static void main_init_screen( void )
if(G.main->scene.first==0) {
set_scene( add_scene("1") );
}
screenmain();
}
int main(int argc, char **argv)
@ -815,6 +813,8 @@ int main(int argc, char **argv)
if (scr_init==0) {
main_init_screen();
}
screenmain(); /* main display loop */
return 0;
} /* end of int main(argc,argv) */