Commit: 35991d999052f6cb7d5c4c98c0c689e05218314c
Author: Campbell Barton
Date:   Fri Oct 26 08:49:10 2018 +1100
Branches: blender2.8
https://developer.blender.org/rB35991d999052f6cb7d5c4c98c0c689e05218314c

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.

===================================================================

M       source/blender/python/intern/bpy_rna_callback.c

===================================================================

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";

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to