backend_gtk and expose_event

Hello everyone,

I have the following problem with my application, which allows you to manipulate some of properties of a plot through the use of a gui-style property editor:

Whenever I set the y-axis scale to logarithmic, but have the y range include a negative value, I will get a ValueError upon expose_event. The bad thing is now, that my application catches all exceptions and displays a user-friendly dialog, explaining or listing the exception and offering the user to mail the output to the dumb author of the program. But whenever the user quits the dialog, a new expose event of the canvas will be triggered, leading to an unstoppable series of exceptions (except when using xkill of course).

So what I would like to propose is a modification of expose_event located in backends/ to better handle any exceptions that it might trigger.
One not so nice solution of mine was to wrap the method in a try...finally statement, which ensures that False is returned and the expose_event is stopped:

    def expose_event(self, widget, event):
        """Expose_event for all GTK backends. Should not be overridden.
        if _debug: print 'FigureCanvasGTK.%s' % fn_name()

        if GTK_WIDGET_DRAWABLE(self):
        if self._need_redraw:
            x, y, w, h = self.allocation
            self._pixmap_prepare (w, h)
            self._render_figure(self._pixmap, w, h)
            self._need_redraw = False

        x, y, w, h = event.area
        self.window.draw_drawable ([self.state],
                       self._pixmap, x, y, x, y, w, h)
        return False # finish event propagation?

Of course, this has the obvious disadvantage, that no exception is triggered at all, which is undesirable.

Are there any better approaches to this?

Best regards,

Niklas Volbers.