30#include "RNA_prototypes.hh"
42 if (screen ==
nullptr) {
61 if (screen->
temp != 0) {
161 PyObject_GC_UnTrack(self);
163 PyObject_GC_Del(self);
217 if (screen ==
nullptr && area ==
nullptr) {
218 PyErr_SetString(PyExc_TypeError,
"Region set with screen & area set to None");
222 PyErr_SetString(PyExc_TypeError,
"Region not found in area or screen");
228 if (win ==
nullptr && screen ==
nullptr) {
229 PyErr_SetString(PyExc_TypeError,
"Area set with window & screen set to None");
233 PyErr_SetString(PyExc_TypeError,
"Area not found in screen");
239 if (win ==
nullptr) {
240 PyErr_SetString(PyExc_TypeError,
"Screen set with null window");
244 PyErr_SetString(PyExc_TypeError,
"Screen not found");
254 PyErr_SetString(PyExc_TypeError,
255 "Overriding context with an active temporary screen isn't supported");
259 PyErr_SetString(PyExc_TypeError,
260 "Overriding context with temporary screen isn't supported");
264 PyErr_SetString(PyExc_TypeError,
"Screen has no workspace");
270 if (&win_iter == win) {
274 PyErr_SetString(PyExc_TypeError,
"Screen is used by another window");
284 PyErr_SetString(PyExc_TypeError,
"Window not found");
332 if (win !=
nullptr) {
361 return Py_NewRef(self);
390 bool do_restore =
true;
405 bool is_container_set =
false;
417 is_container_set =
true;
421 is_container_set =
true;
442 is_container_set =
true;
446 is_container_set =
true;
467 is_container_set =
true;
471 is_container_set =
true;
492 is_container_set =
true;
497 is_container_set =
true;
512 Py_DECREF(context_dict_test);
525 bpy_rna_context_temp_override_logging_set_doc,
526 ".. method:: logging_set(enable, *, hide_missing=False)\n"
528 " Set context member logging options for this temporary override.\n"
530 " :param enable: Enable logging of context member access.\n"
531 " :type enable: bool\n"
532 " :param hide_missing: When true, suppress logging access to members that\n"
533 " are not available in the current context.\n"
534 " :type hide_missing: bool\n");
540 bool hide_missing =
false;
542 static const char *_keywords[] = {
547 static _PyArg_Parser _parser = {
555 if (!_PyArg_ParseTupleAndKeywordsFast(
575# pragma clang diagnostic push
576# pragma clang diagnostic ignored "-Wcast-function-type"
578# pragma GCC diagnostic push
579# pragma GCC diagnostic ignored "-Wcast-function-type"
588 METH_VARARGS | METH_KEYWORDS,
589 bpy_rna_context_temp_override_logging_set_doc},
595# pragma clang diagnostic pop
597# pragma GCC diagnostic pop
602 PyVarObject_HEAD_INIT(
nullptr, 0)
603 "ContextTempOverride",
621 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
662 PyObject *kwds_parse = PyDict_New();
663 for (
int i = 0; kwds_static[i]; i++) {
664 PyObject *key = PyUnicode_FromString(kwds_static[i]);
667 switch (PyDict_Pop(kwds, key, &val)) {
669 if (PyDict_SetItem(kwds_parse, key, val) == -1) {
690 bpy_context_temp_override_doc,
691 ".. method:: temp_override(*, window=None, screen=None, area=None, region=None, **keywords)\n"
693 " Context manager to temporarily override members in the context.\n"
695 " :param window: Window override or None.\n"
696 " :type window: :class:`bpy.types.Window` | None\n"
697 " :param screen: Screen override or None.\n"
699 " .. note:: Switching to or away from full-screen areas & temporary screens "
700 "isn't supported. Passing in these screens will raise an exception, "
701 "actions that leave the context such screens won't restore the prior screen.\n"
703 " .. note:: Changing the screen has wider implications "
704 "than other arguments as it will also change the works-space "
705 "and potentially the scene (when pinned).\n"
707 " :type screen: :class:`bpy.types.Screen` | None\n"
708 " :param area: Area override or None.\n"
709 " :type area: :class:`bpy.types.Area` | None\n"
710 " :param region: Region override or None.\n"
711 " :type region: :class:`bpy.types.Region` | None\n"
712 " :param keywords: Additional keywords override context members.\n"
713 " :return: The context manager.\n"
714 " :rtype: :class:`bpy.types.ContextTempOverride`\n");
718 if (context_ptr ==
nullptr) {
722 if (kwds ==
nullptr) {
729 if (!PyArg_ValidateKeywordArguments(kwds)) {
740 params.window.
type = RNA_Window;
741 params.screen.type = RNA_Screen;
742 params.area.type = RNA_Area;
743 params.region.type = RNA_Region;
745 static const char *
const _keywords[] = {
752 static _PyArg_Parser _parser = {
763 kwds = kwds ? PyDict_Copy(kwds) : PyDict_New();
766 const int parse_result = _PyArg_ParseTupleAndKeywordsFast(args,
777 Py_DECREF(kwds_parse);
788 PyObject *context_dict_current =
static_cast<PyObject *
>(
CTX_py_dict_get(
C));
789 if (context_dict_current !=
nullptr) {
790 PyDict_Merge(kwds, context_dict_current, 0);
795 if (params.window.ptr !=
nullptr) {
796 ctx_temp.
win =
static_cast<wmWindow *
>(params.window.ptr->data);
800 if (params.screen.ptr !=
nullptr) {
801 ctx_temp.
screen =
static_cast<bScreen *
>(params.screen.ptr->data);
805 if (params.area.ptr !=
nullptr) {
806 ctx_temp.
area =
static_cast<ScrArea *
>(params.area.ptr->data);
810 if (params.region.ptr !=
nullptr) {
811 ctx_temp.
region =
static_cast<ARegion *
>(params.region.ptr->data);
818 ret->ctx_temp = ctx_temp;
819 memset(&
ret->ctx_init, 0,
sizeof(
ret->ctx_init));
821 ret->ctx_temp_orig.screen =
nullptr;
825 ret->py_state_context_dict = kwds;
827 PyObject_GC_Track(
ret);
829 return reinterpret_cast<PyObject *
>(
ret);
840# pragma clang diagnostic push
841# pragma clang diagnostic ignored "-Wcast-function-type"
843# pragma GCC diagnostic push
844# pragma GCC diagnostic ignored "-Wcast-function-type"
851 METH_VARARGS | METH_KEYWORDS,
852 bpy_context_temp_override_doc,
857# pragma clang diagnostic pop
859# pragma GCC diagnostic pop
#define BLI_assert_unreachable()
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
static PyObject * bpy_context_temp_override_extract_known_args(const char *const *kwds_static, PyObject *kwds)
ScrArea * CTX_wm_area(const bContext *C)
void * CTX_py_dict_get(const bContext *C)
static bool wm_check_window_exists(const Main *bmain, const wmWindow *win)
static bool bpy_rna_context_temp_override_enter_ok_or_error(const BPyContextTempOverride *self, const Main *bmain, const wmWindow *win, const bScreen *screen, const ScrArea *area, const ARegion *region)
int PyC_ParseBool(PyObject *o, void *p)
static bool wm_check_screen_exists(const Main *bmain, const bScreen *screen)
static PyTypeObject BPyContextTempOverride_Type
void CTX_wm_window_set(bContext *C, wmWindow *win)
PyDoc_STRVAR(bpy_bm_new_doc, ".. function:: new(*, use_operators=True)\n" "\n" " :param use_operators: Support calling operators in :mod:`bmesh.ops` (uses some " "extra memory per vert/edge/face).\n" " :type use_operators: bool\n" " :return: Return a new, empty BMesh.\n" " :rtype: :class:`bmesh.types.BMesh`\n")
static bool wm_check_region_exists(const bScreen *screen, const ScrArea *area, const ARegion *region)
CTX_LogFlag CTX_member_logging_flag_get(const bContext *C)
static PyObject * bpy_rna_context_temp_override_logging_set(BPyContextTempOverride *self, PyObject *args, PyObject *kwds)
static int bpy_rna_context_temp_override_traverse(BPyContextTempOverride *self, visitproc visit, void *arg)
wmWindow * CTX_wm_window(const bContext *C)
void WM_window_set_active_workspace(bContext *C, wmWindow *win, WorkSpace *workspace)
static bool wm_check_screen_switch_supported(const bScreen *screen)
int pyrna_struct_as_ptr_or_null_parse(PyObject *o, void *p)
static int bpy_rna_context_temp_override_clear(BPyContextTempOverride *self)
void WM_window_set_active_screen(wmWindow *win, WorkSpace *workspace, bScreen *screen)
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void CTX_wm_screen_set(bContext *C, bScreen *screen)
static PyMethodDef bpy_rna_context_temp_override_methods[]
WorkSpaceLayout * BKE_workspace_layout_find_global(const Main *bmain, const bScreen *screen, WorkSpace **r_workspace) ATTR_NONNULL(1
void CTX_py_state_push(bContext *C, bContext_PyState *pystate, void *value)
static PyObject * bpy_context_temp_override(PyObject *self, PyObject *args, PyObject *kwds)
void CTX_py_state_pop(bContext *C, bContext_PyState *pystate)
static bool wm_check_area_exists(const wmWindow *win, const bScreen *screen, const ScrArea *area)
const PointerRNA * pyrna_struct_as_ptr(PyObject *py_obj, const StructRNA *srna)
Main * CTX_data_main(const bContext *C)
static void bpy_rna_context_temp_set_screen_for_window(bContext *C, wmWindow *win, bScreen *screen)
PyMethodDef BPY_rna_context_temp_override_method_def
void bpy_rna_context_types_init(PyObject *bpy_types)
bool BKE_screen_is_fullscreen_area(const bScreen *screen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
bScreen * CTX_wm_screen(const bContext *C)
void CTX_wm_region_set(bContext *C, ARegion *region)
static void bpy_rna_context_temp_override_dealloc(BPyContextTempOverride *self)
void CTX_member_logging_flag_set(bContext *C, CTX_LogFlag flag)
bScreen * WM_window_get_active_screen(const wmWindow *win)
ARegion * CTX_wm_region(const bContext *C)
static PyObject * bpy_rna_context_temp_override_enter(BPyContextTempOverride *self)
static PyObject * bpy_rna_context_temp_override_exit(BPyContextTempOverride *self, PyObject *)
void CTX_wm_area_set(bContext *C, ScrArea *area)
header-only compatibility defines.
PyObject * py_state_context_dict
bContext_PyState py_state
struct blender::BPyContextTempOverride::@002306043167116355020201354203267051156052202164 ctx_temp_orig
PyObject_HEAD bContext * context
ListBaseT< wmWindowManager > wm
ListBaseT< bScreen > screens
ListBaseT< ScrArea > areabase
ListBaseT< ARegion > regionbase
ListBaseT< struct ScrArea > areabase
ListBaseT< ARegion > regionbase