FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Gtk crash by mdboom · Pull Request #106 · matplotlib/matplotlib · GitHub

Repository navigation

Gtk crash - #106

Merged
mdboom merged 3 commits into
matplotlib:v1.0.xfrom
mdboom:gtk_crash
May 13, 2011
Merged

mdboom merged 3 commits into
matplotlib:v1.0.xfrom
mdboom:gtk_crash

Conversation

mdboom commented May 6, 2011

Copy link
Copy Markdown
Member

Fix for atexit crash when running GtkAgg backend but not actually showing any windows.

Copy link
Copy Markdown
Member

This would solve the problem at hand, but I am curious about why this problem has shown up now. Could this be a symptom of another bug.

mdboom commented May 12, 2011

Copy link
Copy Markdown
Member Author

I think it's possibly due to recent work to remove some memory leaks in that backend... I'm going to bisect and see if I can get to the bottom of when this began.

mdboom commented May 12, 2011

Copy link
Copy Markdown
Member Author

My suspicion was correct. It came down to a commit that fixed a memory leak when closing figures.

SHA: 354dee8

I think this is the right approach -- the problem is that to destroy things properly we have to actually remove attributes, and since the destruction process is somewhat unpredictable, we don't know in what order they will be destroyed.

Copy link
Copy Markdown
Member

I agree, and am satisfied as to the cause. Should any of this checking also be done for other backends' figure objects? Also, while I am fine with this fix for now, I have to wonder if there is a better way for figures to keep track of what to destroy. This approach of explicitly destroying particular objects leaves open the possibility of future developers forgetting to add another detroy statements for any new additions to the figure class.

mdboom commented May 13, 2011

Copy link
Copy Markdown
Member Author

The need to explicitly destroy objects comes from the design of pygtk. Since we have cyclical references between gtk (i.e. C extension) objects, their del methods will not get called. The only way out of this is to explicitly call "destroy". AFAIK Qt4 and Tk do not suffer this problem. Wx is a bit of a cipher for me in this regard.

This shouldn't affect anything with the Figure class, only the various Gtk-specific backend classes.

Copy link
Copy Markdown
Member

Then I am ok with this patch. Just wanted to do a sanity check.

mdboom added a commit that referenced this pull request May 13, 2011
mdboom merged commit ffd4581 into matplotlib:v1.0.x May 13, 2011

pearu commented May 26, 2011

Copy link
Copy Markdown

I am getting a related AttributeError when closing a figure. Here is a diff that fixes the problem:

diff --git a/lib/matplotlib/backends/backend_gtk.py b/lib/matplotlib/backends/backend_gtk.py
index 142292e..7a853f1 100644
--- a/lib/matplotlib/backends/backend_gtk.py
+++ b/lib/matplotlib/backends/backend_gtk.py
@@ -540,7 +540,8 @@ class FigureManagerGTK(FigureManagerBase):
 
         def notify_axes_change(fig):
             'this will be called whenever the current axes is changed'
-            if self.toolbar is not None: self.toolbar.update()
+            if getattr(self, 'toolbar', None) is not None: 
+                self.toolbar.update()
         self.canvas.figure.add_axobserver(notify_axes_change)
 
         self.canvas.grab_focus()

richbwood mentioned this pull request Dec 19, 2012
mdboom deleted the gtk_crash branch March 3, 2015 18:43
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

3 participants


Back | FazBrowse Home | New Git URL