From 67e8c1e1c7cfbb000de903c9c4e83874adba411f Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 13 Jun 2018 10:57:10 +0200 Subject: Cleanup: remove more G.main from BKE area. --- source/blender/blenkernel/intern/blender.c | 12 +++--- source/blender/blenkernel/intern/blendfile.c | 8 ++-- source/blender/blenkernel/intern/customdata.c | 2 +- source/blender/blenkernel/intern/gpencil.c | 4 +- source/blender/blenkernel/intern/ipo.c | 62 +++++++++++++-------------- source/blender/blenkernel/intern/node.c | 2 +- source/blender/blenkernel/intern/particle.c | 17 +++----- source/blender/blenkernel/intern/pointcache.c | 4 +- 8 files changed, 54 insertions(+), 57 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 55b2d5b9c0d..68bca5d11b9 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -79,9 +79,9 @@ char versionstr[48] = ""; /* only to be called on exit blender */ void BKE_blender_free(void) { - /* samples are in a global list..., also sets G.main->sound->sample NULL */ - BKE_main_free(G.main); - G.main = NULL; + /* samples are in a global list..., also sets G_MAIN->sound->sample NULL */ + BKE_main_free(G_MAIN); + G_MAIN = NULL; if (G.log.file != NULL) { fclose(G.log.file); @@ -123,7 +123,7 @@ void BKE_blender_globals_init(void) U.savetime = 1; - G.main = BKE_main_new(); + G_MAIN = BKE_main_new(); strcpy(G.ima, "//"); @@ -140,9 +140,9 @@ void BKE_blender_globals_init(void) void BKE_blender_globals_clear(void) { - BKE_main_free(G.main); /* free all lib data */ + BKE_main_free(G_MAIN); /* free all lib data */ - G.main = NULL; + G_MAIN = NULL; } /***/ diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c index 935000e3b8e..aa5530704c6 100644 --- a/source/blender/blenkernel/intern/blendfile.c +++ b/source/blender/blenkernel/intern/blendfile.c @@ -113,7 +113,7 @@ static void setup_app_data( bContext *C, BlendFileData *bfd, const char *filepath, ReportList *reports) { - Main *bmain = G.main; /* Valid usage */ + Main *bmain = G_MAIN; Scene *curscene = NULL; const bool is_startup = (bfd->filename[0] == '\0'); const bool recover = (G.fileflags & G_FILE_RECOVER) != 0; @@ -198,7 +198,7 @@ static void setup_app_data( } } - /* BKE_blender_globals_clear will free G.main, here we can still restore pointers */ + /* BKE_blender_globals_clear will free G_MAIN, here we can still restore pointers */ blo_lib_link_screen_restore(bfd->main, curscreen, curscene); /* curscreen might not be set when loading without ui (see T44217) so only re-assign if available */ if (curscreen) { @@ -215,14 +215,14 @@ static void setup_app_data( } } - /* free G.main Main database */ + /* free G_MAIN Main database */ // CTX_wm_manager_set(C, NULL); BKE_blender_globals_clear(); /* clear old property update cache, in case some old references are left dangling */ RNA_property_update_cache_free(); - bmain = G.main = bfd->main; + bmain = G_MAIN = bfd->main; CTX_data_main_set(C, bmain); diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index cf86963cf60..023cf76796d 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -3499,7 +3499,7 @@ bool CustomData_verify_versions(struct CustomData *data, int index) static void customdata_external_filename(char filename[FILE_MAX], ID *id, CustomDataExternal *external) { BLI_strncpy(filename, external->filename, FILE_MAX); - BLI_path_abs(filename, ID_BLEND_PATH(G.main, id)); + BLI_path_abs(filename, ID_BLEND_PATH_FROM_GLOBAL(id)); } void CustomData_external_reload(CustomData *data, ID *UNUSED(id), CustomDataMask mask, int totelem) diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index ee0d0b41898..9b79415f006 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -622,12 +622,12 @@ bGPDpalettecolor *BKE_gpencil_palettecolor_addnew(bGPDpalette *palette, const ch } /* add a new gp-datablock */ -bGPdata *BKE_gpencil_data_addnew(const char name[]) +bGPdata *BKE_gpencil_data_addnew(Main *bmain, const char name[]) { bGPdata *gpd; /* allocate memory for a new block */ - gpd = BKE_libblock_alloc(G.main, ID_GD, name, 0); + gpd = BKE_libblock_alloc(bmain, ID_GD, name, 0); /* initial settings */ gpd->flag = (GP_DATA_DISPINFO | GP_DATA_EXPAND); diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index fe6778e8e56..611c1e3bafb 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -1524,7 +1524,7 @@ static void action_to_animato(ID *id, bAction *act, ListBase *groups, ListBase * * This assumes that AnimData has been added already. Separation of drivers * from animation data is accomplished here too... */ -static void ipo_to_animdata(ID *id, Ipo *ipo, char actname[], char constname[], Sequence *seq) +static void ipo_to_animdata(Main *bmain, ID *id, Ipo *ipo, char actname[], char constname[], Sequence *seq) { AnimData *adt = BKE_animdata_from_id(id); ListBase anim = {NULL, NULL}; @@ -1559,7 +1559,7 @@ static void ipo_to_animdata(ID *id, Ipo *ipo, char actname[], char constname[], BLI_snprintf(nameBuf, sizeof(nameBuf), "CDA:%s", ipo->id.name + 2); - adt->action = BKE_action_add(G.main, nameBuf); + adt->action = BKE_action_add(bmain, nameBuf); if (G.debug & G_DEBUG) printf("\t\tadded new action - '%s'\n", nameBuf); } @@ -1695,19 +1695,19 @@ static void nlastrips_to_animdata(ID *id, ListBase *strips) * clear which datablocks have yet to be converted, and also prevent freeing errors when we exit. */ // XXX currently done after all file reading... -void do_versions_ipos_to_animato(Main *main) +void do_versions_ipos_to_animato(Main *bmain) { ListBase drivers = {NULL, NULL}; ID *id; - if (main == NULL) { + if (bmain == NULL) { printf("Argh! Main is NULL in do_versions_ipos_to_animato()\n"); return; } /* only convert if version is right */ - if (main->versionfile >= 250) { - printf("WARNING: Animation data too new to convert (Version %d)\n", main->versionfile); + if (bmain->versionfile >= 250) { + printf("WARNING: Animation data too new to convert (Version %d)\n", bmain->versionfile); return; } else if (G.debug & G_DEBUG) @@ -1716,7 +1716,7 @@ void do_versions_ipos_to_animato(Main *main) /* ----------- Animation Attached to Data -------------- */ /* objects */ - for (id = main->object.first; id; id = id->next) { + for (id = bmain->object.first; id; id = id->next) { Object *ob = (Object *)id; bPoseChannel *pchan; bConstraint *con; @@ -1731,7 +1731,7 @@ void do_versions_ipos_to_animato(Main *main) /* IPO first to take into any non-NLA'd Object Animation */ if (ob->ipo) { - ipo_to_animdata(id, ob->ipo, NULL, NULL, NULL); + ipo_to_animdata(bmain, id, ob->ipo, NULL, NULL, NULL); id_us_min(&ob->ipo->id); ob->ipo = NULL; @@ -1765,7 +1765,7 @@ void do_versions_ipos_to_animato(Main *main) /* IPO second... */ if (ob->ipo) { - ipo_to_animdata(id, ob->ipo, NULL, NULL, NULL); + ipo_to_animdata(bmain, id, ob->ipo, NULL, NULL, NULL); id_us_min(&ob->ipo->id); ob->ipo = NULL; @@ -1802,7 +1802,7 @@ void do_versions_ipos_to_animato(Main *main) /* although this was the constraint's local IPO, we still need to provide pchan + con * so that drivers can be added properly... */ - ipo_to_animdata(id, con->ipo, pchan->name, con->name, NULL); + ipo_to_animdata(bmain, id, con->ipo, pchan->name, con->name, NULL); id_us_min(&con->ipo->id); con->ipo = NULL; } @@ -1822,7 +1822,7 @@ void do_versions_ipos_to_animato(Main *main) /* although this was the constraint's local IPO, we still need to provide con * so that drivers can be added properly... */ - ipo_to_animdata(id, con->ipo, NULL, con->name, NULL); + ipo_to_animdata(bmain, id, con->ipo, NULL, con->name, NULL); id_us_min(&con->ipo->id); con->ipo = NULL; } @@ -1842,7 +1842,7 @@ void do_versions_ipos_to_animato(Main *main) /* convert Constraint Channel's IPO data */ if (conchan->ipo) { - ipo_to_animdata(id, conchan->ipo, NULL, conchan->name, NULL); + ipo_to_animdata(bmain, id, conchan->ipo, NULL, conchan->name, NULL); id_us_min(&conchan->ipo->id); conchan->ipo = NULL; } @@ -1861,7 +1861,7 @@ void do_versions_ipos_to_animato(Main *main) } /* shapekeys */ - for (id = main->key.first; id; id = id->next) { + for (id = bmain->key.first; id; id = id->next) { Key *key = (Key *)id; if (G.debug & G_DEBUG) printf("\tconverting key %s\n", id->name + 2); @@ -1875,7 +1875,7 @@ void do_versions_ipos_to_animato(Main *main) AnimData *adt = BKE_animdata_add_id(id); /* Convert Shapekey data... */ - ipo_to_animdata(id, key->ipo, NULL, NULL, NULL); + ipo_to_animdata(bmain, id, key->ipo, NULL, NULL, NULL); if (adt->action) adt->action->idroot = key->ipo->blocktype; @@ -1886,7 +1886,7 @@ void do_versions_ipos_to_animato(Main *main) } /* materials */ - for (id = main->mat.first; id; id = id->next) { + for (id = bmain->mat.first; id; id = id->next) { Material *ma = (Material *)id; if (G.debug & G_DEBUG) printf("\tconverting material %s\n", id->name + 2); @@ -1897,7 +1897,7 @@ void do_versions_ipos_to_animato(Main *main) AnimData *adt = BKE_animdata_add_id(id); /* Convert Material data... */ - ipo_to_animdata(id, ma->ipo, NULL, NULL, NULL); + ipo_to_animdata(bmain, id, ma->ipo, NULL, NULL, NULL); if (adt->action) adt->action->idroot = ma->ipo->blocktype; @@ -1908,7 +1908,7 @@ void do_versions_ipos_to_animato(Main *main) } /* worlds */ - for (id = main->world.first; id; id = id->next) { + for (id = bmain->world.first; id; id = id->next) { World *wo = (World *)id; if (G.debug & G_DEBUG) printf("\tconverting world %s\n", id->name + 2); @@ -1919,7 +1919,7 @@ void do_versions_ipos_to_animato(Main *main) AnimData *adt = BKE_animdata_add_id(id); /* Convert World data... */ - ipo_to_animdata(id, wo->ipo, NULL, NULL, NULL); + ipo_to_animdata(bmain, id, wo->ipo, NULL, NULL, NULL); if (adt->action) adt->action->idroot = wo->ipo->blocktype; @@ -1930,7 +1930,7 @@ void do_versions_ipos_to_animato(Main *main) } /* sequence strips */ - for (id = main->scene.first; id; id = id->next) { + for (id = bmain->scene.first; id; id = id->next) { Scene *scene = (Scene *)id; Editing *ed = scene->ed; if (ed && ed->seqbasep) { @@ -1970,7 +1970,7 @@ void do_versions_ipos_to_animato(Main *main) icu->adrcode = adrcode; /* convert IPO */ - ipo_to_animdata((ID *)scene, seq->ipo, NULL, NULL, seq); + ipo_to_animdata(bmain, (ID *)scene, seq->ipo, NULL, NULL, seq); if (adt->action) adt->action->idroot = ID_SCE; /* scene-rooted */ @@ -1984,7 +1984,7 @@ void do_versions_ipos_to_animato(Main *main) /* textures */ - for (id = main->tex.first; id; id = id->next) { + for (id = bmain->tex.first; id; id = id->next) { Tex *te = (Tex *)id; if (G.debug & G_DEBUG) printf("\tconverting texture %s\n", id->name + 2); @@ -1995,7 +1995,7 @@ void do_versions_ipos_to_animato(Main *main) AnimData *adt = BKE_animdata_add_id(id); /* Convert Texture data... */ - ipo_to_animdata(id, te->ipo, NULL, NULL, NULL); + ipo_to_animdata(bmain, id, te->ipo, NULL, NULL, NULL); if (adt->action) adt->action->idroot = te->ipo->blocktype; @@ -2006,7 +2006,7 @@ void do_versions_ipos_to_animato(Main *main) } /* cameras */ - for (id = main->camera.first; id; id = id->next) { + for (id = bmain->camera.first; id; id = id->next) { Camera *ca = (Camera *)id; if (G.debug & G_DEBUG) printf("\tconverting camera %s\n", id->name + 2); @@ -2017,7 +2017,7 @@ void do_versions_ipos_to_animato(Main *main) AnimData *adt = BKE_animdata_add_id(id); /* Convert Camera data... */ - ipo_to_animdata(id, ca->ipo, NULL, NULL, NULL); + ipo_to_animdata(bmain, id, ca->ipo, NULL, NULL, NULL); if (adt->action) adt->action->idroot = ca->ipo->blocktype; @@ -2028,7 +2028,7 @@ void do_versions_ipos_to_animato(Main *main) } /* lamps */ - for (id = main->lamp.first; id; id = id->next) { + for (id = bmain->lamp.first; id; id = id->next) { Lamp *la = (Lamp *)id; if (G.debug & G_DEBUG) printf("\tconverting lamp %s\n", id->name + 2); @@ -2039,7 +2039,7 @@ void do_versions_ipos_to_animato(Main *main) AnimData *adt = BKE_animdata_add_id(id); /* Convert Lamp data... */ - ipo_to_animdata(id, la->ipo, NULL, NULL, NULL); + ipo_to_animdata(bmain, id, la->ipo, NULL, NULL, NULL); if (adt->action) adt->action->idroot = la->ipo->blocktype; @@ -2050,7 +2050,7 @@ void do_versions_ipos_to_animato(Main *main) } /* curves */ - for (id = main->curve.first; id; id = id->next) { + for (id = bmain->curve.first; id; id = id->next) { Curve *cu = (Curve *)id; if (G.debug & G_DEBUG) printf("\tconverting curve %s\n", id->name + 2); @@ -2061,7 +2061,7 @@ void do_versions_ipos_to_animato(Main *main) AnimData *adt = BKE_animdata_add_id(id); /* Convert Curve data... */ - ipo_to_animdata(id, cu->ipo, NULL, NULL, NULL); + ipo_to_animdata(bmain, id, cu->ipo, NULL, NULL, NULL); if (adt->action) adt->action->idroot = cu->ipo->blocktype; @@ -2083,7 +2083,7 @@ void do_versions_ipos_to_animato(Main *main) */ /* actions */ - for (id = main->action.first; id; id = id->next) { + for (id = bmain->action.first; id; id = id->next) { bAction *act = (bAction *)id; if (G.debug & G_DEBUG) printf("\tconverting action %s\n", id->name + 2); @@ -2097,7 +2097,7 @@ void do_versions_ipos_to_animato(Main *main) } /* ipo's */ - for (id = main->ipo.first; id; id = id->next) { + for (id = bmain->ipo.first; id; id = id->next) { Ipo *ipo = (Ipo *)id; if (G.debug & G_DEBUG) printf("\tconverting ipo %s\n", id->name + 2); @@ -2107,7 +2107,7 @@ void do_versions_ipos_to_animato(Main *main) bAction *new_act; /* add a new action for this, and convert all data into that action */ - new_act = BKE_action_add(main, id->name + 2); + new_act = BKE_action_add(bmain, id->name + 2); ipo_to_animato(NULL, ipo, NULL, NULL, NULL, NULL, &new_act->curves, &drivers); new_act->idroot = ipo->blocktype; } diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index d03c11c7b2a..2bebdff10a6 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -2014,7 +2014,7 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree) /* Make full copy outside of Main database. * Note: previews are not copied here. */ - BKE_id_copy_ex(G.main, (ID *)ntree, (ID **)<ree, + BKE_id_copy_ex(NULL, (ID *)ntree, (ID **)<ree, LIB_ID_CREATE_NO_MAIN | LIB_ID_CREATE_NO_USER_REFCOUNT | LIB_ID_COPY_NO_PREVIEW, false); ltree->flag |= NTREE_IS_LOCALIZED; diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 7602523b97c..c064f2e5f71 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3146,7 +3146,7 @@ void psys_mat_hair_to_global(Object *ob, DerivedMesh *dm, short from, ParticleDa /************************************************/ /* ParticleSettings handling */ /************************************************/ -ModifierData *object_add_particle_system(Scene *scene, Object *ob, const char *name) +ModifierData *object_add_particle_system(Main *bmain, Scene *scene, Object *ob, const char *name) { ParticleSystem *psys; ModifierData *md; @@ -3163,7 +3163,7 @@ ModifierData *object_add_particle_system(Scene *scene, Object *ob, const char *n psys->pointcache = BKE_ptcache_add(&psys->ptcaches); BLI_addtail(&ob->particlesystem, psys); - psys->part = BKE_particlesettings_add(NULL, DATA_("ParticleSettings")); + psys->part = BKE_particlesettings_add(bmain, DATA_("ParticleSettings")); if (BLI_listbase_count_at_most(&ob->particlesystem, 2) > 1) BLI_snprintf(psys->name, sizeof(psys->name), DATA_("ParticleSystem %i"), BLI_listbase_count(&ob->particlesystem)); @@ -3186,12 +3186,12 @@ ModifierData *object_add_particle_system(Scene *scene, Object *ob, const char *n psys->flag = PSYS_CURRENT; psys->cfra = BKE_scene_frame_get_from_ctime(scene, CFRA + 1); - DAG_relations_tag_update(G.main); + DAG_relations_tag_update(bmain); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); return md; } -void object_remove_particle_system(Scene *UNUSED(scene), Object *ob) +void object_remove_particle_system(Main *bmain, Scene *UNUSED(scene), Object *ob) { ParticleSystem *psys = psys_get_current(ob); ParticleSystemModifierData *psmd; @@ -3232,7 +3232,7 @@ void object_remove_particle_system(Scene *UNUSED(scene), Object *ob) else ob->mode &= ~OB_MODE_PARTICLE_EDIT; - DAG_relations_tag_update(G.main); + DAG_relations_tag_update(bmain); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } @@ -3321,14 +3321,11 @@ static void default_particle_settings(ParticleSettings *part) } -ParticleSettings *BKE_particlesettings_add(Main *main, const char *name) +ParticleSettings *BKE_particlesettings_add(Main *bmain, const char *name) { ParticleSettings *part; - if (main == NULL) - main = G.main; - - part = BKE_libblock_alloc(main, ID_PA, name, 0); + part = BKE_libblock_alloc(bmain, ID_PA, name, 0); default_particle_settings(part); diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 61971456df3..8d550e09b25 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -3516,7 +3516,7 @@ void BKE_ptcache_quick_cache_all(Main *bmain, Scene *scene) PTCacheBaker baker; memset(&baker, 0, sizeof(baker)); - baker.main = bmain; + baker.bmain = bmain; baker.scene = scene; baker.bake = 0; baker.render = 0; @@ -3541,7 +3541,7 @@ static void ptcache_dt_to_str(char *str, double dtime) /* if bake is not given run simulations to current frame */ void BKE_ptcache_bake(PTCacheBaker *baker) { - Main *bmain = baker->main; + Main *bmain = baker->bmain; Scene *scene = baker->scene; Scene *sce_iter; /* SETLOOPER macro only */ Base *base; -- cgit v1.2.3