Fix the virtual dispatch code for the PGEditor.GetValueFromControl

This commit is contained in:
Robin Dunn
2018-06-04 15:40:47 -07:00
parent 7abb3cd07a
commit d7a546545e
3 changed files with 11 additions and 10 deletions

View File

@@ -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)

View File

@@ -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()

View File

@@ -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);
}
"""