#1141 closed defect (fixed)
GLWindow.OnPaint() broken on Windows
Reported by: | glynn | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | 7.0.0 |
Component: | wxGUI | Version: | unspecified |
Keywords: | nviz, wingrass | Cc: | martinl |
CPU: | All | Platform: | MSWindows XP |
Description
GLWindow.OnPaint() (in nviz_mapdisp.py) calls:
dc = wx.PaintDC(self)
On Windows, wx.PaintDC() can only be called in an EVT_PAINT handler, but GLWindow.OnPaint() is called from at least two other places: GLWindow.OnMouseAction() (nviz_mapdisp.py:226) and MapFrame.AddToolbar() (mapdisp.py:417). The latter causes an exception when switching to "3D View":
Traceback (most recent call last): File "C:\msys\1.0\home\glynn\src\grass-7.0\dist.i686-pc-mingw32\etc\gui\wxpython\gui_modules\toolbars.py", line 322, in OnSelectTool self.parent.AddToolbar("nviz") File "C:\msys\1.0\home\glynn\src\grass-7.0\dist.i686-pc-mingw32\etc\gui\wxpython\gui_modules\mapdisp.py", line 417, in AddToolbar self.MapWindow3D.OnPaint(None) # -> LoadData File "C:\msys\1.0\home\glynn\src\grass-7.0\dist.i686-pc-mingw32\etc\gui\wxpython\gui_modules\nviz_mapdisp.py", line 163, in OnPaint dc = wx.PaintDC(self) File "C:\Program Files\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\_gdi.py", line 4804, in __init__ _gdi_.PaintDC_swiginit(self,_gdi_.new_PaintDC(*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!
I note that the created DC isn't actually used, so I'm assuming this it's being created to keep Windows happy (if you don't create a PaintDC, Windows won't "validate" the rectangle and will just keep send PAINT messages).
I'm also assuming that OnPaint() is being called to ensure that the state gets fully initialised. If you just want to force a redraw, you would normally do so asynchronously using wx.Window.Refresh(). But that won't work if you're counting on OnPaint() having been called before proceeding.
I think that OnPaint() should probably be split into e.g. OnPaint() and DoPaint(), with the latter doing most of the work while the former simply creates the PaintDC then calls DoPaint(). Making this change eliminates the above exception, although the wxGUI crashes shortly afterwards (in Gs_loadmap_as_short(), AFAICT).
PS: I set the "component" field to wxGUI; is NVIZ for the Tcl/Tk NVIZ or for either version?
Attachments (1)
Change History (13)
follow-up: 4 comment:1 by , 14 years ago
comment:2 by , 14 years ago
Cc: | added |
---|---|
Keywords: | wingrass added |
follow-up: 8 comment:3 by , 14 years ago
Replying to glynn:
although the wxGUI crashes shortly afterwards (in Gs_loadmap_as_short(), AFAICT).
FWIW, this should be fixed by r43279. fmode.o doesn't help with libraries which are loaded at run-time (e.g. via ctypes), which meant that open() was opening files in text mode, resulting in EOF at the first Ctrl-Z byte (\x1a), as well as performing CRLF->LF conversion.
With the OnPaint/DoPaint change (r43280), wxNviz now works (for me) on Windows, although using it does result in Python crashing when you quit the GUI.
follow-up: 5 comment:4 by , 14 years ago
Replying to martinl:
Replying to glynn:
PS: I set the "component" field to wxGUI; is NVIZ for the Tcl/Tk NVIZ or for either version?
this component is related to TCL/TK-based NVIZ. I have renamed it to "TCL/TK NVIZ" to avoid confusion.
Does that make any bugs tagged against the prior "NVIZ" now orphaned in the db, or do they follow? I had also thought to rename SWIG component -> ctypes, but stalled as I worried about this issue.
(and fwiw "Tcl/Tk" not "TCL/TK" :)
Hamish
follow-up: 6 comment:5 by , 14 years ago
Replying to hamish:
Does that make any bugs tagged against the prior "NVIZ" now orphaned in the db, or do they follow? I had also thought to rename SWIG component -> ctypes, but stalled as I worried about this issue.
seems to follow, see e.g.
(and fwiw "Tcl/Tk" not "TCL/TK" :)
right, http://en.wikipedia.org/wiki/Tcl/tk - renamed.
Martin
comment:6 by , 14 years ago
Replying to martinl:
(and fwiw "Tcl/Tk" not "TCL/TK" :)
right, http://en.wikipedia.org/wiki/Tcl/tk - renamed.
now
comment:7 by , 14 years ago
Replying to martinl:
Replying to hamish:
Does that make any bugs tagged against the prior "NVIZ" now orphaned in the db, or do they follow? I had also thought to rename SWIG component -> ctypes, but stalled as I worried about this issue.
seems to follow, see e.g.
excellent. SWIG component now renamed to "Python ctypes" too. (it turns out there were only about 4 open+closed of those in total)
(and fwiw "Tcl/Tk" not "TCL/TK" :)
right, http://en.wikipedia.org/wiki/Tcl/tk - renamed.
& I guess technically it should be called nViz as it is short for the n-dimensional visualizer, but no need to fight the years of momentum.. :)
now back to your regularly scheduled bug report, Hamish
follow-up: 9 comment:8 by , 14 years ago
Replying to glynn: [...]
With the OnPaint/DoPaint change (r43280), wxNviz now works (for me) on Windows, although using it does result in Python crashing when you quit the GUI.
see also ticket #1134
now tested with a self compiled wingrass7-installer at r43283, wxnviz is also working for me for the first time. there is no crashing by quit the GUI at my side.
Helmut
follow-up: 11 comment:9 by , 14 years ago
Replying to hellik:
[...]there is no crashing by quit the GUI at my side.
I was to early, also a python crash by quit the GUI here.
and after switch back to the 2d-view-mode, there are relicts of the 3dview-mode buttons in the map layers tab (see screenshot)
Helmut
by , 14 years ago
Attachment: | WinGrass7_nviz_26082010_220351.png added |
---|
comment:10 by , 14 years ago
Milestone: | 6.4.0 → 7.0.0 |
---|
follow-up: 12 comment:11 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
The OnPaint error is fixed now, so I'm closing the ticket.
Replying to hellik:
and after switch back to the 2d-view-mode, there are relicts of the 3dview-mode buttons in the map layers tab (see screenshot)
If this problem still exist, please open a new ticket. The GUI crash should be fixed (r53246).
Anna
Replying to glynn:
this component is related to TCL/TK-based NVIZ. I have renamed it to "TCL/TK NVIZ" to avoid confusion.