segfault related to NavigationToolbar when using PySide

Hi everybody,

The following is a small test yielding a segmentation fault with PySide, but
not with PyQt4.

To test with PyQt4, use:
$ python example.py

To test with PySide:
$ python example.py pyside

With PySide, a segmentation fault appears as soon as the mouse cursor is
hovering the plot area. Without the NavigationToolbar (try to comment the
corresponding lines), the problem does not appear. It may be related to the
display of mouse coordinates in the NavigationToolbar, because when the mouse
is hovering the NavigationToolbar, no segfault appears.

These are the versions of Qt, PySide, and Matplotlib on my machine:

from PySide import QtCore
QtCore.qVersion()

'4.8.1'

from PySide import __version__
__version__

'1.1.0'

import matplotlib
matplotlib.__version__

'1.1.1rc'

Is this a bug? If yes, does any workaround exist?

Thanks in advance,

TP

########### example.py ############
#!/usr/bin/env python

import sys

if len(sys.argv) >= 2 and sys.argv[1] == "pyside":
    from os import environ
    environ['QT_API'] = 'pyside'

    from PySide.QtCore import *
    from PySide.QtGui import *
else:
    from PyQt4.QtCore import *
    from PyQt4.QtGui import *

from matplotlib.figure import Figure
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as
FigureCanvas
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg

class MplCanvasXY( FigureCanvas ):

    def __init__( self, title = None, xlabel = None, ylabel = None,
parent=None ):

        self.fig = Figure()
        self.axes = self.fig.add_subplot(111)
        self.axes.grid(True)

        FigureCanvas.__init__( self, self.fig )
        self.setParent( parent )

app = QApplication( sys.argv )
d = QDialog()

vb = QVBoxLayout()
canvas = MplCanvasXY()

vb.addWidget( canvas )
navigationToolbar = NavigationToolbar2QTAgg(
        parent = canvas
        , canvas = canvas )
vb.addWidget( navigationToolbar )
d.setLayout( vb )

d.show()
sys.exit( app.exec_() )

Hi everybody,

The following is a small test yielding a segmentation fault with PySide, but
not with PyQt4.

To test with PyQt4, use:
$ python example.py

To test with PySide:
$ python example.py pyside

With PySide, a segmentation fault appears as soon as the mouse cursor is
hovering the plot area. Without the NavigationToolbar (try to comment the
corresponding lines), the problem does not appear. It may be related to the
display of mouse coordinates in the NavigationToolbar, because when the mouse
is hovering the NavigationToolbar, no segfault appears.

These are the versions of Qt, PySide, and Matplotlib on my machine:

from PySide import QtCore
QtCore.qVersion()

'4.8.1'

from PySide import __version__
__version__

'1.1.0'

import matplotlib
matplotlib.__version__

'1.1.1rc'

Is this a bug? If yes, does any workaround exist?

Yes, it's a bug, but most likely in PySide. Mpl does not use any extension code specific to Qt.

Eric

ยทยทยท

On 2012/07/05 11:33 PM, TP wrote:

Thanks in advance,

TP

########### example.py ############
#!/usr/bin/env python

import sys

if len(sys.argv) >= 2 and sys.argv[1] == "pyside":
     from os import environ
     environ['QT_API'] = 'pyside'

     from PySide.QtCore import *
     from PySide.QtGui import *
else:
     from PyQt4.QtCore import *
     from PyQt4.QtGui import *

from matplotlib.figure import Figure
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as
FigureCanvas
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg

class MplCanvasXY( FigureCanvas ):

     def __init__( self, title = None, xlabel = None, ylabel = None,
parent=None ):

         self.fig = Figure()
         self.axes = self.fig.add_subplot(111)
         self.axes.grid(True)

         FigureCanvas.__init__( self, self.fig )
         self.setParent( parent )

app = QApplication( sys.argv )
d = QDialog()

vb = QVBoxLayout()
canvas = MplCanvasXY()

vb.addWidget( canvas )
navigationToolbar = NavigationToolbar2QTAgg(
         parent = canvas
         , canvas = canvas )
vb.addWidget( navigationToolbar )
d.setLayout( vb )

d.show()
sys.exit( app.exec_() )

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options