From dd79937d435946d8ec8482573ece63ef008b950d Mon Sep 17 00:00:00 2001 From: Jonathan Hoffstadt Date: Mon, 25 Apr 2022 13:50:47 -0500 Subject: [PATCH] fix: get_value returning deleted value option for listbox #1640 --- DearPyGui/src/ui/AppItems/mvBasicWidgets.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/DearPyGui/src/ui/AppItems/mvBasicWidgets.cpp b/DearPyGui/src/ui/AppItems/mvBasicWidgets.cpp index 436898024..90f98b3f3 100644 --- a/DearPyGui/src/ui/AppItems/mvBasicWidgets.cpp +++ b/DearPyGui/src/ui/AppItems/mvBasicWidgets.cpp @@ -1150,6 +1150,25 @@ DearPyGui::set_configuration(PyObject* inDict, mvListboxConfig& outConfig, mvApp } index++; } + + if (!outConfig.value->empty()) + { + if (!outConfig.names.empty()) + { + bool oldValueFound = false; + for (int i = 0; i < outConfig.names.size(); i++) + { + if (outConfig.names[i] == *outConfig.value) + { + oldValueFound = true; + break; + } + } + + if(!oldValueFound) + *outConfig.value = outConfig.names[0]; + } + } } if(outConfig.value->empty())