Merge pull request #877 from RobinD42/fix-issue742

Fix GetValueFromControl and StringToValue
(cherry picked from commit 53c03f9203)
This commit is contained in:
Robin Dunn
2018-06-04 20:38:23 -07:00
parent 1d8485c380
commit 5d011f4f04
5 changed files with 27 additions and 10 deletions

View File

@@ -153,6 +153,13 @@ Changes in this release include the following:
* Hide the window when the tool does not fit into AuiToolBar. (#872)
* 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)
* Fixed all implementations of the PGProperty.StringToValue and IntToValue
methods to treat the value parameter as a return value. (#742)

View File

@@ -481,7 +481,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()
@@ -489,8 +489,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).
@@ -507,7 +506,6 @@ class TrivialPropertyEditor(wxpg.PGEditor):
def OnFocus(self, property, ctrl):
ctrl.SetSelection(-1,-1)
ctrl.SetFocus()

View File

@@ -59,6 +59,12 @@ def run():
if hasattr(item, 'type') and 'wxVariant' in item.type:
item.type = item.type.replace('wxVariant', 'wxPGVariant')
# Switch all StringToValue and IntToValue methods to return the variant
# value instead of using it as a parameter.
for item in module.allItems():
if (item.name in ['StringToValue', 'IntToValue'] and item.findItem('variant')):
item.find('variant').out = True
# Deprecated aliases for the various helper classes in Classic
module.addPyCode("""\

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

View File

@@ -101,6 +101,12 @@ def run():
if hasattr(item, 'type') and 'wxVariant' in item.type:
item.type = item.type.replace('wxVariant', 'wxPGVariant')
# Switch all StringToValue and IntToValue methods to return the variant
# value instead of using it as a parameter.
for item in module.allItems():
if (item.name in ['StringToValue', 'IntToValue'] and item.findItem('variant')):
item.find('variant').out = True
#-----------------------------------------------------------------
tools.doCommonTweaks(module)
tools.runGenerators(module)