[wxPython] Gdk-CRITICALerrors on Linux, runs great on Win32

OK, I am a huge proponent of wxPython, but yesterday's debacle almost made
me wish I was writing C++ code.

So here's the deal. I have a medium size application that worked great in
Python 1.5.2/wxPython 2.1.x, but used the old Grid class. I knew sooner or
later I would have to re-write, it so this past month, I've undertaken that
task. I have upgraded to Python 2.1 and wxPython 2.3.1. In place of the
old grid, I decided to use a wxListCtrl since it really does all I need.

Since I only had a Win2000 box at home, I did the entire re-write under
Windows. The program run flawlessly there and is an improvement over the
previous version. Yesterday, I finally managed to get the entire dependency
chain built and installed on my RH 7.1 machine.

I have:

RH 7.1
KDE 2.1
Python 2.1
Numeric 20.1
PyOpenGl 2.0.44
Gtk 1.2.9
wxGTK 2.3.1 built with --with-gtk --with-opengl
wxPython 2.3.1 built with default setup

The wxPython demo runs great. I only get a couple of errors throughout all
the demos. Specifically, the OpenGL demo does run.

So, feeling great, I check out my source from CVS, fire up the program, and
I get 10,000 (actually 9889) Gdk-CRITICAL errors, plus a max recursion error
shown below:

Gdk-CRITICAL **: file gdkgc.c: line 713 (gdk_gc_set_clip_region): assertion
`gc != NULL' failed.

Gdk-CRITICAL **: file gdkgc.c: line 713 (gdk_gc_set_clip_region): assertion
`gc != NULL' failed.

Gdk-CRITICAL **: file gdkgc.c: line 713 (gdk_gc_set_clip_region): assertion
`gc != NULL' failed.

Gdk-CRITICAL **: file gdkgc.c: line 713 (gdk_gc_set_clip_region): assertion
`gc != NULL' failed.
Exception exceptions.RuntimeError: 'maximum recursion depth exceeded' in
<method wxSizePtr.__del__ of wxSizePtr instance at 0x858156c> ignored
Traceback (most recent call last):
  File "./mviewglcanvas.py", line 121, in OnPaint
    self.InitGL()
  File "./mviewglcanvas.py", line 246, in InitGL
    size = self.GetClientSize()
  File "/software/LINUX/lib/python2.1/site-packages/wxPython/windows.py",
line 185, in GetClientSize
    if val: val = wxSizePtr(val) ; val.thisown = 1
RuntimeError: maximum recursion depth exceeded

Gdk-CRITICAL **: file gdkgc.c: line 456 (gdk_gc_set_foreground): assertion
`gc != NULL' failed.

Gdk-CRITICAL **: file gdkgc.c: line 469 (gdk_gc_set_background): assertion
`gc != NULL' failed.

Gdk-CRITICAL **: file gdkgc.c: line 562 (gdk_gc_set_fill): assertion `gc !=
NULL' failed.

Finally, when I close the app, I get a core dump that clearly doesn't happen
on Win32.

This is not a complicated app, the basic layout is a wxFrame, a menu bar, a
toolbar, and the main area is a wxSplitterWindow with a wxListCtrl on the
left and an OpenGL canvas on the right.

Since I get none of these errors on Win32 and since none of the demos
generate this type of error on Linux, I am mainly looking for a place to
start debugging. I suppose it could be some weird issue with the type of
widget that is allowed to be a parent for another kind of widget. Based on
the recursion error above, it could be that I am trying to get the size of a
window after it is constructed but before it is shown, and this behavior is
different on Linux than Windows.

I doubt I am the first to see this problem, but I've never seen it mentioned
on the mailing list.

Thanks for any input.

Bob

Robert W. Tolbert, Ph.D.
Senior Principal Systems Engineer p. (203) 778-7840
Boehringer Ingelheim Pharma. Inc. f. (203) 798-5660
175 Briar Ridge Road
Ridgefield, CT 06877

Finally, when I close the app, I get a core dump that clearly doesn't

happen

on Win32.

This is not a complicated app, the basic layout is a wxFrame, a menu bar,

a

toolbar, and the main area is a wxSplitterWindow with a wxListCtrl on the
left and an OpenGL canvas on the right.

Since I get none of these errors on Win32 and since none of the demos
generate this type of error on Linux, I am mainly looking for a place to
start debugging. I suppose it could be some weird issue with the type of
widget that is allowed to be a parent for another kind of widget. Based

on

the recursion error above, it could be that I am trying to get the size of

a

window after it is constructed but before it is shown, and this behavior

is

different on Linux than Windows.

That's a definite possibility. In wxGTK the underlying X window is not
created immediately while in wxMSW it is. There is a EVT_WINDOW_CREATE
event that you can catch if you determine that some things can't be done
until after the window is created.

My guess is that it may be some OpenGL stuff that is happening too early.
What happens if you replace the wxGLCanvas with some other window, a wxPanel
or something? Do you do any GL specific function calls in the __init__ of a
wxGLCanvas derived class that would cause a repaint or something?

You may also want to reconfigure wxGTK with the --enable-debug flags so you
get the wxASSERTs and such, and then rebuild it and wxPython. There may be
some situation that is caught and asserted in the debug version and will
give you a message with a clue that can help you figure it out.

Otherwise, please reduce it to a small sample that shows the problem and
send it to me.

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!