The Qt4 backend crashes with a Segmentation Fault when no toolbar is
requested. For example:
from matplotlib import pyplot as plt
from matplotlib import rcParams
rcParams['toolbar'] = 'None'
fig=plt.figure()
plt.show()
I have attached a possible patch, but since I've never really touched
the Qt4 backend before, thought I'd solicit some feedback before committing.
Mike
--
Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA
Index: backend_qt4.py
===================================================================
--- backend_qt4.py (revision 8402)
+++ backend_qt4.py (working copy)
@@ -314,16 +314,19 @@
self.window._destroying = False
self.toolbar = self._get_toolbar(self.canvas, self.window)
- self.window.addToolBar(self.toolbar)
- QtCore.QObject.connect(self.toolbar, QtCore.SIGNAL("message"),
- self.window.statusBar().showMessage)
+ if self.toolbar is not None:
+ self.window.addToolBar(self.toolbar)
+ QtCore.QObject.connect(self.toolbar, QtCore.SIGNAL("message"),
+ self.window.statusBar().showMessage)
+ tbs_height = self.toolbar.sizeHint().height()
+ else:
+ tbs_height = 0
# resize the main window so it will display the canvas with the
# requested size:
cs = canvas.sizeHint()
- tbs = self.toolbar.sizeHint()
sbs = self.window.statusBar().sizeHint()
- self.window.resize(cs.width(), cs.height()+tbs.height()+sbs.height())
+ self.window.resize(cs.width(), cs.height()+tbs_height+sbs.height())
self.window.setCentralWidget(self.canvas)
@@ -335,7 +338,8 @@
def notify_axes_change( fig ):
# This will be called whenever the current axes is changed
- if self.toolbar != None: self.toolbar.update()
+ if self.toolbar is not None:
+ self.toolbar.update()
self.canvas.figure.add_axobserver( notify_axes_change )
def _widgetclosed( self ):
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel