From 33612926ae1abdb2790019f83fac6189735db28f Mon Sep 17 00:00:00 2001 From: Jonathan Hoffstadt Date: Fri, 21 Oct 2022 22:44:38 -0500 Subject: [PATCH] fix: custom series delete crash issue #1864 --- src/dearpygui_commands.h | 3 ++- src/mvPythonTranslator.cpp | 22 +++++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/dearpygui_commands.h b/src/dearpygui_commands.h index b2cf2c562..064124112 100644 --- a/src/dearpygui_commands.h +++ b/src/dearpygui_commands.h @@ -2999,7 +2999,8 @@ delete_item(PyObject* self, PyObject* args, PyObject* kwargs) mvUUID item = GetIDFromPyObject(itemraw); - DeleteItem((*GContext->itemRegistry), item, childrenOnly, slot); + if(item != 0) + DeleteItem((*GContext->itemRegistry), item, childrenOnly, slot); return GetPyNone(); diff --git a/src/mvPythonTranslator.cpp b/src/mvPythonTranslator.cpp index 4b568a330..890ca2c1b 100644 --- a/src/mvPythonTranslator.cpp +++ b/src/mvPythonTranslator.cpp @@ -273,9 +273,11 @@ ToPyList(const std::vector& value) PyObject* result = PyList_New(value.size()); - for (size_t i = 0; i < value.size(); ++i) - PyList_SetItem(result, i, PyFloat_FromDouble(value[i])); - + if(result) + { + for (size_t i = 0; i < value.size(); ++i) + PyList_SetItem(result, i, PyFloat_FromDouble(value[i])); + } return result; } @@ -284,8 +286,11 @@ ToPyList(const std::vector>& value) { PyObject* result = PyList_New(value.size()); - for (size_t i = 0; i < value.size(); ++i) - PyList_SetItem(result, i, ToPyList(value[i])); + if(result) + { + for (size_t i = 0; i < value.size(); ++i) + PyList_SetItem(result, i, ToPyList(value[i])); + } return result; } @@ -295,8 +300,11 @@ ToPyList(const std::vector>& value) { PyObject* result = PyList_New(value.size()); - for (size_t i = 0; i < value.size(); ++i) - PyList_SetItem(result, i, ToPyList(value[i])); + if(result) + { + for (size_t i = 0; i < value.size(); ++i) + PyList_SetItem(result, i, ToPyList(value[i])); + } return result; }