| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
…wing any windows.
|
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. |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
|
Then I am ok with this patch. Just wanted to do a sanity check. |
Sorry, something went wrong.
|
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()
|
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Fix for atexit crash when running GtkAgg backend but not actually showing any windows.