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

Markus Metz markus.metz.giswork at googlemail.com
Fri Feb 24 16:28:32 EST 2012


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


More information about the grass-dev mailing list