Bug in matplotlib_gtk ?

Its difficult to say if its bug in backend_gtk.py, it depends on exactly
what your application is doing. You would need to post a minimal test
case that demonstrates the bug so we could see whats going on.

Steve

Send instant messages to your online friends http://au.messenger.yahoo.com

···

On Wed, 2006-02-15 at 20:36 -0800, matplotlib-devel-request@lists.sourceforge.net wrote:

Hello,

    I'm using matplotlib figures in several places at a time in my GTK
based app (means different page in a notebook).
I have trace a bug I partially solved but still doubting if it is a
matplotlib bug or a bad design of my app.

Matplotlib 0.86.2
pygtk-2.8.4
gtk+-2.8.6

Here is the problem:

in matplotlib/backends/backend_gtk.py file, in
class FigureCanvasGTK (gtk.DrawingArea, FigureCanvasBase):
... in:

def draw(self):
        # synchronous window redraw (like GTK+ 1.2 used to do)
        # Note: this does not follow the usual way that GTK redraws,
        # which is asynchronous redraw using calls to
gtk_widget_queue_draw(),
        # which triggers an expose-event

        # GTK+ 2.x style draw()
  1- self._need_redraw = True
  1- self.queue_draw()

        # synchronous draw (needed for animation)
  2- x, y, w, h = self.allocation
  2- if w<3 or h<3: return # empty fig

  2- self._pixmap_prepare (w, h)
  2- self._render_figure(self._pixmap, w, h)
  2- self._need_redraw = False
  2- self.window.draw_drawable (self.style.fg_gc[self.state],
  2- self._pixmap, 0, 0, 0, 0, w, h)

If I use method 1- (and comment 2-) no problem, all run smoothly...
But using the default method, switching on method 2- (and comment 1-)
I get the followig error message when trying to redraw one of the
figure
(the figure is plotted correctly the first time. No change made to the
figure, just redrawing...)

***/python2.4/site-packages/matplotlib/backends/backend_gtk.py:298:
GtkWarning: gdk_pixmap_new: assertion `(drawable != NULL) || (depth !=
-1)' failed
  self._pixmap_height)
Traceback (most recent call last):
...
    self.canvas_leak.draw()
  File
"***/python2.4/site-packages/matplotlib/backends/backend_gtk.py", line
250, in draw
    self._pixmap_prepare (w, h)
  File
"***/python2.4/site-packages/matplotlib/backends/backend_gtk.py", line
298, in _pixmap_prepare
    self._pixmap_height)
RuntimeError: could not create GdkPixmap object

Somebody has a clue ???

Here is a quick and dirty minimal code reproducing the problem.

David

2006/2/17, Steve Chaplin <stevech1097@…49…>:

test_mpl_bug.py (1.02 KB)

···

On Wed, 2006-02-15 at 20:36 -0800, > matplotlib-devel-request@lists.sourceforge.net wrote:

Hello,

I'm using matplotlib figures in several places at a time in my GTK

based app (means different page in a notebook).
I have trace a bug I partially solved but still doubting if it is a
matplotlib bug or a bad design of my app.

Matplotlib 0.86.2
pygtk-2.8.4
gtk±2.8.6

Here is the problem:

in matplotlib/backends/backend_gtk.py file, in
class FigureCanvasGTK (gtk.DrawingArea, FigureCanvasBase):
… in:

def draw(self):
# synchronous window redraw (like GTK+ 1.2 used to do)
# Note: this does not follow the usual way that GTK redraws,
# which is asynchronous redraw using calls to

gtk_widget_queue_draw(),
# which triggers an expose-event

    # GTK+ 2.x style draw()

1- self._need_redraw = True
1- self.queue_draw()

    # synchronous draw (needed for animation)

2- x, y, w, h = self.allocation
2- if w<3 or h<3: return # empty fig

2- self._pixmap_prepare (w, h)
2- self._render_figure(self._pixmap, w, h)
2- self._need_redraw = False

2- self.window.draw_drawable (self.style.fg_gc[self.state],

2-
self._pixmap, 0, 0, 0, 0, w, h)

If I use method 1- (and comment 2-) no problem, all run smoothly…
But using the default method, switching on method 2- (and comment 1-)
I get the followig error message when trying to redraw one of the

figure
(the figure is plotted correctly the first time. No change made to the
figure, just redrawing…)

***/python2.4/site-packages/matplotlib/backends/backend_gtk.py:298:
GtkWarning: gdk_pixmap_new: assertion `(drawable != NULL) || (depth !=

-1)’ failed
self._pixmap_height)
Traceback (most recent call last):

self.canvas_leak.draw()
File
“***/python2.4/site-packages/matplotlib/backends/backend_gtk.py”, line

250, in draw
self._pixmap_prepare (w, h)
File
“***/python2.4/site-packages/matplotlib/backends/backend_gtk.py”, line
298, in _pixmap_prepare
self._pixmap_height)

RuntimeError: could not create GdkPixmap object

Somebody has a clue ???

Its difficult to say if its bug in backend_gtk.py, it depends on exactly
what your application is doing. You would need to post a minimal test

case that demonstrates the bug so we could see whats going on.

Steve

Send instant messages to your online friends http://au.messenger.yahoo.com

Note:
The “crash” only occurs if you run the script and press directly the replot button.
If you click on the second page of the notebook then back to the first and “replot”
no problem. Though no problem at all if the “# GTK+ 2.x style draw()” is used in

matplotlib_gtk.py

Regards,

David

2006/2/19, David TREMOUILLES <david.trem@…149…>:

···

Here is a quick and dirty minimal code reproducing the problem.

David

2006/2/17, Steve Chaplin <stevech1097@…49…>:

On Wed, 2006-02-15 at 20:36 -0800, > > matplotlib-devel-request@lists.sourceforge.net > > wrote:

Hello,

I'm using matplotlib figures in several places at a time in my GTK

based app (means different page in a notebook).
I have trace a bug I partially solved but still doubting if it is a
matplotlib bug or a bad design of my app.

Matplotlib 0.86.2

pygtk-2.8.4
gtk±2.8.6

Here is the problem:

in matplotlib/backends/backend_gtk.py file, in
class FigureCanvasGTK (gtk.DrawingArea, FigureCanvasBase):
… in:

def draw(self):
# synchronous window redraw (like GTK+ 1.2 used to do)
# Note: this does not follow the usual way that GTK redraws,
# which is asynchronous redraw using calls to

gtk_widget_queue_draw(),
# which triggers an expose-event

    # GTK+ 2.x style draw()

1- self._need_redraw = True
1- self.queue_draw()

    # synchronous draw (needed for animation)

2- x, y, w, h = self.allocation
2- if w<3 or h<3: return # empty fig

2- self._pixmap_prepare (w, h)
2- self._render_figure(self._pixmap, w, h)
2- self._need_redraw = False

2- self.window.draw_drawable (self.style.fg_gc[self.state],

2-
self._pixmap, 0, 0, 0, 0, w, h)

If I use method 1- (and comment 2-) no problem, all run smoothly…
But using the default method, switching on method 2- (and comment 1-)
I get the followig error message when trying to redraw one of the

figure
(the figure is plotted correctly the first time. No change made to the
figure, just redrawing…)

***/python2.4/site-packages/matplotlib/backends/backend_gtk.py:298:
GtkWarning: gdk_pixmap_new: assertion `(drawable != NULL) || (depth !=

-1)’ failed
self._pixmap_height)
Traceback (most recent call last):

self.canvas_leak.draw()
File
“***/python2.4/site-packages/matplotlib/backends/backend_gtk.py”, line

250, in draw
self._pixmap_prepare (w, h)
File
“***/python2.4/site-packages/matplotlib/backends/backend_gtk.py”, line
298, in _pixmap_prepare
self._pixmap_height)

RuntimeError: could not create GdkPixmap object

Somebody has a clue ???

Its difficult to say if its bug in backend_gtk.py, it depends on exactly
what your application is doing. You would need to post a minimal test

case that demonstrates the bug so we could see whats going on.

Steve

Send instant messages to your online friends
http://au.messenger.yahoo.com