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
diff --git a/pgadmin/frm/frmEditGrid.cpp b/pgadmin/frm/frmEditGrid.cpp
index edf403f..b1a861d 100644
--- a/pgadmin/frm/frmEditGrid.cpp
+++ b/pgadmin/frm/frmEditGrid.cpp
@@ -1611,7 +1611,14 @@ public:
 	}
 	void Create(wxWindow *parent, wxWindowID id, wxEvtHandler *evtHandler);
 	void BeginEdit(int row, int col, wxGrid *grid);
+
+
+#if wxCHECK_VERSION(2, 9, 0)	
+	void ApplyEdit(int row, int col, wxGrid *grid); // pure virtual in wx 2.9+, doesn't exist in prior versions
+	bool EndEdit(int row, int col, const wxGrid *grid, const wxString&, wxString*);
+#else
 	bool EndEdit(int row, int col, wxGrid *grid);
+#endif
 	wxString GetValue() const;
 	virtual void Reset()
 	{
@@ -1663,7 +1670,20 @@ void sqlGridTextEditor::DoBeginEdit(const wxString &startValue)
 	Text()->SetFocus();
 }
 
+#if wxCHECK_VERSION(2, 9, 0)
+// pure virtual in 2.9+, doesn't exist in prior versions
+void sqlGridTextEditor::ApplyEdit(int row, int col, wxGrid *grid)
+{
+	wxString value = Text()->GetText();
+	grid->GetTable()->SetValue(row, col, value);
+}
+#endif
+
+#if wxCHECK_VERSION(2, 9, 0)
+bool sqlGridTextEditor::EndEdit(int row, int col, const wxGrid *grid, const wxString&, wxString*)
+#else
 bool sqlGridTextEditor::EndEdit(int row, int col, wxGrid *grid)
+#endif
 {
 	bool changed = false;
 	wxString value = Text()->GetText();
@@ -1671,8 +1691,10 @@ bool sqlGridTextEditor::EndEdit(int row, int col, wxGrid *grid)
 	if (value != m_startValue)
 		changed = true;
 
+#if !wxCHECK_VERSION(2, 9, 0)
 	if (changed)
 		grid->GetTable()->SetValue(row, col, value);
+#endif
 
 	return changed;
 }
@@ -1723,7 +1745,12 @@ public:
 
 	virtual bool IsAcceptedKey(wxKeyEvent &event);
 	virtual void BeginEdit(int row, int col, wxGrid *grid);
-	virtual bool EndEdit(int row, int col, wxGrid *grid);
+#if wxCHECK_VERSION(2, 9, 0)	
+	void ApplyEdit(int row, int col, wxGrid *grid); // pure virtual in wx 2.9+, doesn't exist in prior versions
+	bool EndEdit(int row, int col, const wxGrid *grid, const wxString&, wxString*);
+#else
+	bool EndEdit(int row, int col, wxGrid *grid);
+#endif
 
 	virtual void Reset()
 	{
@@ -1836,9 +1863,22 @@ void sqlGridNumericEditor::BeginEdit(int row, int col, wxGrid *grid)
 	DoBeginEdit(value);
 }
 
+#if wxCHECK_VERSION(2, 9, 0)
+// pure virtual in 2.9+, doesn't exist in prior versions
+void sqlGridNumericEditor::ApplyEdit(int row, int col, wxGrid *grid)
+{
+	wxString value = Text()->GetValue();
+	grid->GetTable()->SetValue(row, col, value);
+	m_startValue = wxEmptyString;
+	Text()->SetValue(m_startValue);
+}
+#endif
 
-
+#if wxCHECK_VERSION(2, 9, 0)
+bool sqlGridNumericEditor::EndEdit(int row, int col, const wxGrid *grid, const wxString&, wxString*)
+#else
 bool sqlGridNumericEditor::EndEdit(int row, int col, wxGrid *grid)
+#endif
 {
 	wxASSERT_MSG(m_control,
 	             wxT("The sqlGridNumericEditor must be Created first!"));
@@ -1851,12 +1891,13 @@ bool sqlGridNumericEditor::EndEdit(int row, int col, wxGrid *grid)
 	if (value != m_startValue)
 		changed = true;
 
+#if !wxCHECK_VERSION(2, 9, 0)
 	if (changed)
 		grid->GetTable()->SetValue(row, col, value);
 
 	m_startValue = wxEmptyString;
 	Text()->SetValue(m_startValue);
-
+#endif
 	return changed;
 }
 
diff --git a/xtra/wx-build/build-wxgtk b/xtra/wx-build/build-wxgtk
index e3439bc..48cf2b1 100755
--- a/xtra/wx-build/build-wxgtk
+++ b/xtra/wx-build/build-wxgtk
@@ -8,53 +8,31 @@ fi
 
 cd $1
 
-cd contrib
 
-
-make clean
-cd ..
 make clean
 ./configure --with-gtk --enable-gtk2 --enable-unicode --enable-mimetype=no --disable-shared --enable-debug
 make all
 make install
-cd contrib
-make all
-make install
 
 
 make clean
-cd ..
-make clean
 ./configure --with-gtk --enable-gtk2 --enable-unicode --enable-mimetype=no --disable-shared --disable-debug
 make all
 make install
-cd contrib
-make all
-make install
 
 
 make clean
-cd ..
-make clean
 ./configure --with-gtk --enable-gtk2 --enable-unicode --enable-mimetype=no --enable-shared --enable-debug
 make all
 make install
-cd contrib
-make all
-make install
 
 
 make clean
-cd .. 
-make clean
 ./configure --with-gtk --enable-gtk2 --enable-unicode --enable-mimetype=no --enable-shared --disable-debug
 make all
 make install
-cd contrib
-make all
-make install
 
-cd ../utils/hhp2cached
+cd ./utils/hhp2cached
 make all
 make install
 cd ../wxrc
-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers

Reply via email to