Cleanup: assign Main, use existing assignments

Avoid accessing inline since it's often used multiple times.

In some cases it was already defined.
This commit is contained in:
Campbell Barton 2020-02-19 15:06:14 +11:00
parent 9f8dd4f9e5
commit 3afe218a7d
12 changed files with 25 additions and 15 deletions

View File

@ -1557,8 +1557,9 @@ static void MARKER_OT_rename(wmOperatorType *ot)
static int ed_marker_make_links_scene_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
ListBase *markers = ED_context_get_markers(C);
Scene *scene_to = BLI_findlink(&CTX_data_main(C)->scenes, RNA_enum_get(op->ptr, "scene"));
Scene *scene_to = BLI_findlink(&bmain->scenes, RNA_enum_get(op->ptr, "scene"));
TimeMarker *marker, *marker_new;
if (scene_to == NULL) {

View File

@ -6871,6 +6871,7 @@ static char *progress_tooltip_func(bContext *UNUSED(C), void *argN, const char *
void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
{
Main *bmain = CTX_data_main(C);
wmWindowManager *wm = CTX_wm_manager(C);
ScrArea *sa = CTX_wm_area(C);
uiBlock *block;
@ -6884,7 +6885,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
Scene *scene;
/* another scene can be rendering too, for example via compositor */
for (scene = CTX_data_main(C)->scenes.first; scene; scene = scene->id.next) {
for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
if (WM_jobs_test(wm, scene, WM_JOB_TYPE_ANY)) {
handle_event = B_STOPOTHER;
icon = ICON_NONE;

View File

@ -1326,7 +1326,7 @@ static int collection_instance_add_exec(bContext *C, wmOperator *op)
}
}
else {
collection = BLI_findlink(&CTX_data_main(C)->collections, RNA_enum_get(op->ptr, "collection"));
collection = BLI_findlink(&bmain->collections, RNA_enum_get(op->ptr, "collection"));
}
if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, NULL, &local_view_bits, NULL)) {

View File

@ -836,14 +836,15 @@ static bool select_grouped_parent(bContext *C) /* Makes parent active and de-sel
/* Select objects in the same group as the active */
static bool select_grouped_collection(bContext *C, Object *ob)
{
Main *bmain = CTX_data_main(C);
bool changed = false;
Collection *collection, *ob_collections[COLLECTION_MENU_MAX];
int collection_count = 0, i;
uiPopupMenu *pup;
uiLayout *layout;
for (collection = CTX_data_main(C)->collections.first;
collection && collection_count < COLLECTION_MENU_MAX;
for (collection = bmain->collections.first;
collection && (collection_count < COLLECTION_MENU_MAX);
collection = collection->id.next) {
if (BKE_collection_has_object(collection, ob)) {
ob_collections[collection_count] = collection;

View File

@ -6065,7 +6065,8 @@ void paint_proj_stroke_done(void *ps_handle_p)
/* use project paint to re-apply an image */
static int texture_paint_camera_project_exec(bContext *C, wmOperator *op)
{
Image *image = BLI_findlink(&CTX_data_main(C)->images, RNA_enum_get(op->ptr, "image"));
Main *bmain = CTX_data_main(C);
Image *image = BLI_findlink(&bmain->images, RNA_enum_get(op->ptr, "image"));
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
ProjPaintState ps = {NULL};

View File

@ -209,7 +209,7 @@ static int open_exec(bContext *C, wmOperator *op)
RNA_string_get(op->ptr, "directory", dir_only);
if (relative) {
BLI_path_rel(dir_only, CTX_data_main(C)->name);
BLI_path_rel(dir_only, bmain->name);
}
prop = RNA_struct_find_property(op->ptr, "files");

View File

@ -3199,6 +3199,7 @@ void IMAGE_OT_pack(wmOperatorType *ot)
static int image_unpack_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Image *ima = image_from_context(C);
int method = RNA_enum_get(op->ptr, "method");
@ -3206,7 +3207,7 @@ static int image_unpack_exec(bContext *C, wmOperator *op)
if (RNA_struct_property_is_set(op->ptr, "id")) {
char imaname[MAX_ID_NAME - 2];
RNA_string_get(op->ptr, "id", imaname);
ima = BLI_findstring(&CTX_data_main(C)->images, imaname, offsetof(ID, name) + 2);
ima = BLI_findstring(&bmain->images, imaname, offsetof(ID, name) + 2);
if (!ima) {
ima = image_from_context(C);
}

View File

@ -587,6 +587,7 @@ void NLA_OT_view_frame(wmOperatorType *ot)
/* add the specified action as new strip */
static int nlaedit_add_actionclip_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
bAnimContext ac;
Scene *scene;
@ -608,7 +609,7 @@ static int nlaedit_add_actionclip_exec(bContext *C, wmOperator *op)
cfra = (float)CFRA;
/* get action to use */
act = BLI_findlink(&CTX_data_main(C)->actions, RNA_enum_get(op->ptr, "action"));
act = BLI_findlink(&bmain->actions, RNA_enum_get(op->ptr, "action"));
if (act == NULL) {
BKE_report(op->reports, RPT_ERROR, "No valid action to add");

View File

@ -1926,6 +1926,7 @@ static void actionset_id_cb(TreeElement *UNUSED(te),
static int outliner_action_set_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
SpaceOutliner *soops = CTX_wm_space_outliner(C);
int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0;
@ -1938,7 +1939,7 @@ static int outliner_action_set_exec(bContext *C, wmOperator *op)
set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
/* get action to use */
act = BLI_findlink(&CTX_data_main(C)->actions, RNA_enum_get(op->ptr, "action"));
act = BLI_findlink(&bmain->actions, RNA_enum_get(op->ptr, "action"));
if (act == NULL) {
BKE_report(op->reports, RPT_ERROR, "No valid action to add");

View File

@ -348,7 +348,7 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op)
start_frame = RNA_int_get(op->ptr, "frame_start");
channel = RNA_int_get(op->ptr, "channel");
sce_seq = BLI_findlink(&CTX_data_main(C)->scenes, RNA_enum_get(op->ptr, "scene"));
sce_seq = BLI_findlink(&bmain->scenes, RNA_enum_get(op->ptr, "scene"));
if (sce_seq == NULL) {
BKE_report(op->reports, RPT_ERROR, "Scene not found");
@ -420,6 +420,7 @@ void SEQUENCER_OT_scene_strip_add(struct wmOperatorType *ot)
/* add movieclip operator */
static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, true);
@ -432,7 +433,7 @@ static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op)
start_frame = RNA_int_get(op->ptr, "frame_start");
channel = RNA_int_get(op->ptr, "channel");
clip = BLI_findlink(&CTX_data_main(C)->movieclips, RNA_enum_get(op->ptr, "clip"));
clip = BLI_findlink(&bmain->movieclips, RNA_enum_get(op->ptr, "clip"));
if (clip == NULL) {
BKE_report(op->reports, RPT_ERROR, "Movie clip not found");
@ -504,6 +505,7 @@ void SEQUENCER_OT_movieclip_strip_add(struct wmOperatorType *ot)
static int sequencer_add_mask_strip_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, true);
@ -516,7 +518,7 @@ static int sequencer_add_mask_strip_exec(bContext *C, wmOperator *op)
start_frame = RNA_int_get(op->ptr, "frame_start");
channel = RNA_int_get(op->ptr, "channel");
mask = BLI_findlink(&CTX_data_main(C)->masks, RNA_enum_get(op->ptr, "mask"));
mask = BLI_findlink(&bmain->masks, RNA_enum_get(op->ptr, "mask"));
if (mask == NULL) {
BKE_report(op->reports, RPT_ERROR, "Mask not found");

View File

@ -820,13 +820,14 @@ static int text_refresh_pyconstraints_exec(bContext *UNUSED(C), wmOperator *UNUS
{
#ifdef WITH_PYTHON
# if 0
Main *bmain = CTX_data_main(C);
Text *text = CTX_data_edit_text(C);
Object *ob;
bConstraint *con;
short update;
/* check all pyconstraints */
for (ob = CTX_data_main(C)->objects.first; ob; ob = ob->id.next) {
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
update = 0;
if (ob->type == OB_ARMATURE && ob->pose) {
bPoseChannel *pchan;

View File

@ -267,7 +267,7 @@ void WM_check(bContext *C)
/* wm context */
if (wm == NULL) {
wm = CTX_data_main(C)->wm.first;
wm = bmain->wm.first;
CTX_wm_manager_set(C, wm);
}