Thanks to visit codestin.com
Credit goes to github.com

Skip to content

hexbin_demo.py crashes with gtk backend #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 13, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/matplotlib/backends/backend_gdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def draw_image(self, gc, x, y, im):
def draw_text(self, gc, x, y, s, prop, angle, ismath):
x, y = int(x), int(y)

if x <0 or y <0: # window has shrunk and text is off the edge
if x < 0 or y < 0: # window has shrunk and text is off the edge
return

if angle not in (0,90):
Expand All @@ -157,6 +157,9 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath):
else:
layout, inkRect, logicalRect = self._get_pango_layout(s, prop)
l, b, w, h = inkRect
if (x + w > self.width or y + h > self.height):
return

self.gdkDrawable.draw_layout(gc.gdkGC, x, y-h-b, layout)


Expand Down Expand Up @@ -225,7 +228,8 @@ def _draw_rotated_text(self, gc, x, y, s, prop, angle):
x = int(x-h)
y = int(y-w)

if x < 0 or y < 0: # window has shrunk and text is off the edge
if (x < 0 or y < 0 or: # window has shrunk and text is off the edge
x + w > self.width or y + h > self.height):
return

key = (x,y,s,angle,hash(prop))
Expand Down