[GRASS-dev] wxGUI: save display to graphic file bug

In the wxGUI, "save display to graphic file" is not working in
wingrass and should not work in linux, because SaveToFile uses
wx.BufferedPaintDC() which is in this case illegal because it can only
be used inside of an EVT_PAINT event handler [0], and SaveToFile is
not an EVT_PAINT event handler, that handler is OnPaint. The last bit
of the traceback is

_gdi_.BufferedPaintDC_swiginit(self,_gdi_.new_BufferedPaintD
C(*args, **kwargs))
wx._core
.
PyAssertionError
:
C++ assertion "wxAssertFailure" failed at
..\..\src\msw\dcclient.cpp(219) in wxPaintDC::wxPaintDC():
wxPaintDC may be created only in EVT_PAINT handler!

This affects all branches and the just released 6.4.2.

A fix for 6.4.svn would be:

--- mapwindow.py (revision 50929)
+++ mapwindow.py (working copy)
@@ -471,7 +471,7 @@
             # set back old coordinates
             textinfo['coords'] = oldCoords

- dc = wx.BufferedPaintDC(self, ibuffer)
+ dc = wx.BufferedDC(None, ibuffer)
         dc.Clear()
         self.PrepareDC(dc)
         self.pdc.DrawToDC(dc)

Works for me on Linux and Windows.

Markus M

[0] http://wxpython.org/docs/api/wx.BufferedPaintDC-class.html

Hi Markus,

2012/2/24 Markus Metz <markus.metz.giswork@googlemail.com>:

In the wxGUI, "save display to graphic file" is not working in
wingrass and should not work in linux, because SaveToFile uses
wx.BufferedPaintDC() which is in this case illegal because it can only
be used inside of an EVT_PAINT event handler [0], and SaveToFile is
not an EVT_PAINT event handler, that handler is OnPaint. The last bit
of the traceback is

right, could you apply the patch? Thanks. Martin

--
Martin Landa <landa.martin gmail.com> * http://geo.fsv.cvut.cz/~landa

On Tue, Mar 20, 2012 at 7:10 PM, Martin Landa <landa.martin@gmail.com> wrote:

Hi Markus,

2012/2/24 Markus Metz <markus.metz.giswork@googlemail.com>:

In the wxGUI, "save display to graphic file" is not working in
wingrass and should not work in linux, because SaveToFile uses
wx.BufferedPaintDC() which is in this case illegal because it can only
be used inside of an EVT_PAINT event handler [0], and SaveToFile is
not an EVT_PAINT event handler, that handler is OnPaint. The last bit
of the traceback is

right, could you apply the patch? Thanks. Martin

Already done 5 days ago for all branches in r51068, r51075, r51076.

Markus M

--
Martin Landa <landa.martin gmail.com> * http://geo.fsv.cvut.cz/~landa