From 50c09563d01f4656fd8d3080981f86f6bfbb59c5 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 19 Mar 2003 03:28:36 +0000 Subject: [PATCH] Fixed problem where the wrong class name could sometimes be used for OOR git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@19610 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/src/helpers.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/wxPython/src/helpers.cpp b/wxPython/src/helpers.cpp index 0c8d4c2e63..f2fe70f69e 100644 --- a/wxPython/src/helpers.cpp +++ b/wxPython/src/helpers.cpp @@ -622,13 +622,19 @@ PyObject* wxPyClassExists(const wxString& className) { if (!className) return NULL; - if ((item = PyDict_GetItemString(wxPyPtrTypeMap, (char*)(const char*)name.mbc_str())) != NULL) { - name = wxString(PyString_AsString(item), *wxConvCurrent); - } - + // Try the name as-is first sprintf(buff, "%sPtr", (const char*)name.mbc_str()); PyObject* classobj = PyDict_GetItemString(wxPython_dict, buff); + // if not found see if there is a mapped name for it + if ( ! classobj) { + if ((item = PyDict_GetItemString(wxPyPtrTypeMap, (char*)(const char*)name.mbc_str())) != NULL) { + name = wxString(PyString_AsString(item), *wxConvCurrent); + sprintf(buff, "%sPtr", (const char*)name.mbc_str()); + classobj = PyDict_GetItemString(wxPython_dict, buff); + } + } + return classobj; // returns NULL if not found }