Thread: wxWidgets 2.9 compatibility: Fix for sefault on table editor under GTK
I should have spotted this one sooner, but I was thrown off by the fact that my sqlGridTextEditor code (inherits wxGridCellTextEditor) compiled without having appropriate EndEdit()/ApplyEdit() signature changes. sqlGridBoolEditor (inherits from wxGridCellEditor), on the other hand, made ApplyEdit and EndEdit() with the new signature pure to avoid this problem. I've reported the inconsistency to wx-users. Attached patch fixes segfault, and makes us consistent with this design principle of 2.9 for grid cells, from wx docs: virtual bool wxGridCellEditor::EndEdit ( int row, int col, const wxGrid * grid, const wxString & oldval, wxString * newval ) [pure virtual] End editing the cell. This function must check if the current value of the editing control is valid and different from the original value (available as oldval in its string form and possibly saved internally using its real type by BeginEdit()). If it isn't, it just returns false, otherwise it must do the following: # Save the new value internally so that ApplyEdit() could apply it. # Fill newval (which is never NULL) with the string representation of the new value. # Return true ****Notice that it must not modify the grid as the change could still be vetoed.**** I've made sqlGridNumericEditor do the same, even though it was ostensibly well behaved before, because changes could still be vetoed before we get to ApplyEdit(). Naturally, 2.8 compatibility is preserved. I've also updated the build shell script to remove contrib/OGL stuff, which we no longer need regardless of wx version. BTW, the comment "// pure virtual in wx 2.9+, doesn't exist in prior versions" isn't currently true for wxGridCellTextEditor inheriting classes, but I left it there in anticipation of it becoming true and for consistency with sqlGridBoolEditor. -- Regards, Peter Geoghegan
Attachment
Re: wxWidgets 2.9 compatibility: Fix for sefault on table editor under GTK
From
Peter Geoghegan
Date:
You can remove the new "// pure virtual in wx 2.9+, doesn't exist in prior versions" comments, because wxGridCellTextEditor is intended to be a concrete class. -- Regards, Peter Geoghegan
Thanks - applied. On Fri, Feb 25, 2011 at 8:31 PM, Peter Geoghegan <peter.geoghegan86@gmail.com> wrote: > I should have spotted this one sooner, but I was thrown off by the > fact that my sqlGridTextEditor code (inherits wxGridCellTextEditor) > compiled without having appropriate EndEdit()/ApplyEdit() signature > changes. sqlGridBoolEditor (inherits from wxGridCellEditor), on the > other hand, made ApplyEdit and EndEdit() with the new signature pure > to avoid this problem. I've reported the inconsistency to wx-users. > > Attached patch fixes segfault, and makes us consistent with this > design principle of 2.9 for grid cells, from wx docs: > > virtual bool wxGridCellEditor::EndEdit ( int row, > int col, > const wxGrid * grid, > const wxString & oldval, > wxString * newval > ) [pure virtual] > End editing the cell. > This function must check if the current value of the editing control > is valid and different from the original value (available as oldval in > its string form and possibly saved internally using its real type by > BeginEdit()). If it isn't, it just returns false, otherwise it must do > the following: # Save the new value internally so that ApplyEdit() > could apply it. # Fill newval (which is never NULL) with the string > representation of the new value. # Return true > > ****Notice that it must not modify the grid as the change could still > be vetoed.**** > > I've made sqlGridNumericEditor do the same, even though it was > ostensibly well behaved before, because changes could still be vetoed > before we get to ApplyEdit(). Naturally, 2.8 compatibility is > preserved. > > I've also updated the build shell script to remove contrib/OGL stuff, > which we no longer need regardless of wx version. > > BTW, the comment "// pure virtual in wx 2.9+, doesn't exist in prior > versions" isn't currently true for wxGridCellTextEditor inheriting > classes, but I left it there in anticipation of it becoming true and > for consistency with sqlGridBoolEditor. > > -- > Regards, > Peter Geoghegan > > > -- > Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgadmin-hackers > > -- Dave Page Blog: http://pgsnake.blogspot.com Twitter: @pgsnake EnterpriseDB UK: http://www.enterprisedb.com The Enterprise PostgreSQL Company