From d7a546545e79c1948de21f53868df90730ebbdf2 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Mon, 4 Jun 2018 15:40:47 -0700 Subject: [PATCH] Fix the virtual dispatch code for the PGEditor.GetValueFromControl --- CHANGES.rst | 3 +++ demo/PropertyGrid.py | 6 ++---- etg/propgrideditors.py | 12 ++++++------ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 676a0389..56800931 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -118,6 +118,9 @@ Changes in this release include the following: result, instead of an integer as was expected. Using floordiv ('//') instead to solve the problem. (#865) +* Fixed the virtual dispatch code for the PGEditor.GetValueFromControl method + to properly pass the parameters to the Python implementation, and also fixed + how the return value is handled. (#742) diff --git a/demo/PropertyGrid.py b/demo/PropertyGrid.py index 3216388b..f9beaebe 100644 --- a/demo/PropertyGrid.py +++ b/demo/PropertyGrid.py @@ -479,7 +479,7 @@ class TrivialPropertyEditor(wxpg.PGEditor): def GetValueFromControl(self, property, ctrl): """ Return tuple (wasSuccess, newValue), where wasSuccess is True if - different value was acquired succesfully. + different value was acquired successfully. """ tc = ctrl textVal = tc.GetValue() @@ -487,8 +487,7 @@ class TrivialPropertyEditor(wxpg.PGEditor): if property.UsesAutoUnspecified() and not textVal: return (True, None) - res, value = property.StringToValue(textVal, - wxpg.PG_EDITABLE_VALUE) + res, value = property.StringToValue(textVal, wxpg.PG_FULL_VALUE) # Changing unspecified always causes event (returning # True here should be enough to trigger it). @@ -505,7 +504,6 @@ class TrivialPropertyEditor(wxpg.PGEditor): def OnFocus(self, property, ctrl): ctrl.SetSelection(-1,-1) - ctrl.SetFocus() diff --git a/etg/propgrideditors.py b/etg/propgrideditors.py index 75e9abf0..e51143aa 100644 --- a/etg/propgrideditors.py +++ b/etg/propgrideditors.py @@ -49,18 +49,18 @@ def run(): m = c.find('GetValueFromControl') m.find('variant').out = True - # Change the virtual method handler code to follow the same pattern as the - # tweaked public API, namely that the value is the return value instead of - # an out parameter. + # Change the virtual method handler code for GetValueFromControl to follow + # the same pattern as the tweaked public API, namely that the value is the + # return value instead of an out parameter. m.cppSignature = 'bool (wxVariant& variant, wxPGProperty* property, wxWindow* ctrl)' m.virtualCatcherCode = """\ - PyObject *sipResObj = sipCallMethod(0, sipMethod, "DDD", + PyObject *sipResObj = sipCallMethod(&sipIsErr, sipMethod, "DD", property, sipType_wxPGProperty, NULL, ctrl, sipType_wxWindow, NULL); if (sipResObj == Py_None) { sipRes = false; - } else { - sipParseResult(&sipIsErr, sipMethod, sipResObj, "bH5", &sipRes, sipType_wxPGVariant, &variant); + } else if (sipResObj && !sipIsErr) { + sipParseResult(&sipIsErr, sipMethod, sipResObj, "(bH5)", &sipRes, sipType_wxPGVariant, &variant); } """