diff --git a/CHANGES.rst b/CHANGES.rst index a96d397c..6050c46a 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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) + diff --git a/demo/PropertyGrid.py b/demo/PropertyGrid.py index d2edf8e1..054cddb6 100644 --- a/demo/PropertyGrid.py +++ b/demo/PropertyGrid.py @@ -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() diff --git a/etg/propgridadvprops.py b/etg/propgridadvprops.py index 5f5e3ae3..782d1931 100644 --- a/etg/propgridadvprops.py +++ b/etg/propgridadvprops.py @@ -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("""\ 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); } """ diff --git a/etg/propgridprops.py b/etg/propgridprops.py index 2f5ef405..0382d91f 100644 --- a/etg/propgridprops.py +++ b/etg/propgridprops.py @@ -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)