Skip to content

Catch the exception thrown by AGG#751

Merged
jwiggins merged 2 commits into
masterfrom
fix/uncaught-exception
Mar 24, 2021
Merged

Catch the exception thrown by AGG#751
jwiggins merged 2 commits into
masterfrom
fix/uncaught-exception

Conversation

@jwiggins
Copy link
Copy Markdown
Member

Resolves #750

This is basically the same change as celiagg/celiagg#97, but with SWIG exception handling instead of Cython. A test has also been added to show that the error is now recoverable.

(Celiagg keeps its rasterizer instance around between draw calls, so it needed an additional change to the AGG code which is not needed here)

Copy link
Copy Markdown
Contributor

@rahulporuri rahulporuri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread kiva/agg/src/graphics_context.i
Comment thread kiva/tests/test_agg_drawing.py Outdated
@rahulporuri
Copy link
Copy Markdown
Contributor

I tested this branch against the code in enthought/chaco#474 and it works as expected. On the main branch, python just halted quietly (with some additional information when we use the -Xfaulthandler flag). On this branch, I get a much cleaner error -

Traceback (most recent call last):
  File "c:\users\rporuri\work\github\ets\enable\enable\qt4\base_window.py", line 243, in paintEvent
    self.handler.paintEvent(event)
  File "c:\users\rporuri\work\github\ets\enable\enable\qt4\base_window.py", line 78, in paintEvent
    self._enable_window._paint(event)
  File "c:\users\rporuri\work\github\ets\enable\enable\abstract_window.py", line 538, in _paint
    self.component.draw(gc, view_bounds=(0, 0, size[0], size[1]))
  File "c:\users\rporuri\work\github\ets\enable\enable\component.py", line 418, in draw
    self._draw(gc, view_bounds, mode)
  File "c:\users\rporuri\work\github\ets\enable\enable\component.py", line 799, in _draw
    self._dispatch_draw(layer, gc, view_bounds, mode)
  File "c:\users\rporuri\work\github\ets\enable\enable\container.py", line 280, in _dispatch_draw
    component._dispatch_draw(layer, gc, new_bounds, mode)
  File "c:\users\rporuri\work\github\ets\enable\enable\component.py", line 817, in _dispatch_draw
    handler(gc, view_bounds, mode)
  File "c:\users\rporuri\work\github\ets\chaco\chaco\base_xy_plot.py", line 463, in _draw_plot
    self._draw_component(gc, view_bounds, mode)
  File "c:\users\rporuri\work\github\ets\chaco\chaco\base_xy_plot.py", line 471, in _draw_component
    self._render(gc, pts)
  File "c:\users\rporuri\work\github\ets\chaco\chaco\lineplot.py", line 325, in _render
    render(gc, points, self.orientation)
  File "c:\users\rporuri\work\github\ets\chaco\chaco\lineplot.py", line 336, in _render_normal
    gc.stroke_path()
  File "c:\users\rporuri\work\github\ets\enable\kiva\agg\agg.py", line 1360, in stroke_path
    return _agg.GraphicsContextArray_stroke_path(self, *args)
OverflowError: Exceeded cell block limit

Comment on lines +187 to +188
with Image.open(filename) as image:
dpi = image.info['dpi']
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drive-by fix. This caused a ResourceWarning when I was running the tests (which I hadn't seen before).

@jwiggins jwiggins merged commit 4c94e8e into master Mar 24, 2021
@jwiggins jwiggins deleted the fix/uncaught-exception branch March 24, 2021 15:20
@jwiggins
Copy link
Copy Markdown
Member Author

Thanks for the review/testing

jwiggins added a commit that referenced this pull request Mar 24, 2021
jwiggins added a commit that referenced this pull request Mar 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle std::overflow_error exception from AGG

2 participants