/* go back to the last occurance of name in stack */ void BKE_undo_name(bContext *C, const char *name) { UndoElem *uel = BLI_rfindstring(&undobase, name, offsetof(UndoElem, name)); if (uel && uel->prev) { curundo = uel->prev; BKE_undo_step(C, 0); } }
/* name optional */ int BKE_undo_valid(const char *name) { if (name) { UndoElem *uel = BLI_rfindstring(&undobase, name, offsetof(UndoElem, name)); return uel && uel->prev; } return undobase.last != undobase.first; }
static int ctx_data_get(bContext *C, const char *member, bContextDataResult *result) { int done= 0, recursion= C->data.recursion; int ret= 0; memset(result, 0, sizeof(bContextDataResult)); #ifdef WITH_PYTHON if(CTX_py_dict_get(C)) { return BPY_context_member_get(C, member, result); // if (BPY_context_member_get(C, member, result)) // return 1; } #endif /* we check recursion to ensure that we do not get infinite * loops requesting data from ourselfs in a context callback */ /* Ok, this looks evil... * if(ret) done= -(-ret | -done); * * Values in order of importance * (0, -1, 1) - Where 1 is highest priority * */ if(done!=1 && recursion < 1 && C->wm.store) { bContextStoreEntry *entry; C->data.recursion= 1; entry= BLI_rfindstring(&C->wm.store->entries, member, offsetof(bContextStoreEntry, name)); if(entry) { result->ptr= entry->ptr; done= 1; } } if(done!=1 && recursion < 2 && C->wm.region) { C->data.recursion= 2; if(C->wm.region->type && C->wm.region->type->context) { ret = C->wm.region->type->context(C, member, result); if(ret) done= -(-ret | -done); } } if(done!=1 && recursion < 3 && C->wm.area) { C->data.recursion= 3; if(C->wm.area->type && C->wm.area->type->context) { ret = C->wm.area->type->context(C, member, result); if(ret) done= -(-ret | -done); } } if(done!=1 && recursion < 4 && C->wm.screen) { bContextDataCallback cb= C->wm.screen->context; C->data.recursion= 4; if(cb) { ret = cb(C, member, result); if(ret) done= -(-ret | -done); } } C->data.recursion= recursion; return done; }