diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-10-26 00:49:10 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-10-26 00:49:10 +0300 |
commit | 35991d999052f6cb7d5c4c98c0c689e05218314c (patch) | |
tree | a30c18c7b7a67eb264b55da4c66390b10f15a2e0 /source/blender/python/intern/bpy_rna_callback.c | |
parent | 1d8ba9d6184bf0e1e1e8fb7b8f41ec74b6ed39f8 (diff) |
PyAPI: Temp workaround for crash removing cursor
Opening a new file frees the cursors,
add check if the cursor is still valid.
This leaks a Python reference, so a better solution is needed.
Diffstat (limited to 'source/blender/python/intern/bpy_rna_callback.c')
-rw-r--r-- | source/blender/python/intern/bpy_rna_callback.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/source/blender/python/intern/bpy_rna_callback.c b/source/blender/python/intern/bpy_rna_callback.c index 521fc518c62..fd475ba503f 100644 --- a/source/blender/python/intern/bpy_rna_callback.c +++ b/source/blender/python/intern/bpy_rna_callback.c @@ -33,6 +33,7 @@ #include "RNA_types.h" #include "BLI_utildefines.h" +#include "BLI_listbase.h" #include "bpy_rna.h" #include "bpy_rna_callback.h" @@ -387,12 +388,18 @@ PyObject *pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *ar } bContext *C = BPy_GetContext(); struct wmWindowManager *wm = CTX_wm_manager(C); - customdata = WM_paint_cursor_customdata_get(handle); - if (!WM_paint_cursor_end(wm, handle)) { - PyErr_SetString(PyExc_ValueError, "draw_cursor_remove(handler): cursor wasn't found"); - return NULL; + + if (BLI_findindex(&wm->paintcursors, handle) == -1) { + /* FIXME(campbell): window manager has freed cursor, need to resolve refcount leak. */ + } + else { + customdata = WM_paint_cursor_customdata_get(handle); + if (!WM_paint_cursor_end(wm, handle)) { + PyErr_SetString(PyExc_ValueError, "draw_cursor_remove(handler): cursor wasn't found"); + return NULL; + } + Py_DECREF((PyObject *)customdata); } - Py_DECREF((PyObject *)customdata); } else if (RNA_struct_is_a(srna, &RNA_Space)) { const char *error_prefix = "Space.draw_handler_remove"; |