Resize error with Qt4 backend

Hello Darren,

Darren Dale <dsdale24@...287...> writes:

I can't produce a segfault with the attached script. I have Qt-4.5.2,
PyQt-4.5.1, and a checkout of the matplotlib trunk.

OK, in this context it seems to work.

I attach a script that shows the problem.

Run it, move the second diagram below the first, adjust their sizes so
that they take roughly the same size:

···

+---------------+-------+

Diagram 1 | |
              > >
              > Hello |

+---------------+ World |

Diagram 2 | |
              > >
              > >

+---------------+-------+

(you will see that the Diagram 2 will not always update properly :frowning: [*] )
and then move the slider between the diagrams and the "Hello World"
label. There is a good chance that the program will segfault. If it does
not, increase the number of points in the diagrams.

BTW, could you reproduce my last example with diagram and scrollbar? It
still remains unsolved (and is reproduced here [*]).

Versions (all 64 bit):

openSUSE 11.1:
Qt Open Source Edition 4.4.3
PyQt 4.4.3
Matplotlib 0.98.5.2

Kubuntu 9.04:
Qt Open Source Edition 4.5.0
PyQt 4.4.4
Matplotlib 0.98.5.2

Best regards

Ole
------------------------------------8<---------------------------------------
import random
import sys

from PyQt4 import QtGui, QtCore
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure,SubplotParams

class AppForm(QtGui.QMainWindow):

    def __init__(self, parent=None):
        QtGui.QMainWindow.__init__(self, parent)

        self.create_dock_widgets()
        self.resize(700, 600)

    def create_dock_widgets(self):
        self.setDockNestingEnabled(True)
        w1 = QtGui.QDockWidget('Diagram 1', self)
        self.addDockWidget(QtCore.Qt.TopDockWidgetArea, w1)
        w1.setWidget(InnerDiagramWidget(self))
        w2 = QtGui.QDockWidget('Diagram 2', self)
        self.addDockWidget(QtCore.Qt.TopDockWidgetArea, w2)
        w2.setWidget(InnerDiagramWidget(self))

        w3 = QtGui.QDockWidget('Label', self)
        self.addDockWidget(QtCore.Qt.TopDockWidgetArea, w3)
        w3.setWidget(QtGui.QLabel('Hello World'))
    
class InnerDiagramWidget(FigureCanvas):
    def __init__(self, parent):
        fig = Figure()
        self.axes = fig.add_subplot(111)
        # Increase this number to rise your chances for a segfault.
        range = xrange(1000)
        l = [ random.randint(-5, 5) for i in range ]
        self.axes.plot(range, l, drawstyle='steps')
        FigureCanvas.__init__(self, fig)
        self.setParent(parent)
        FigureCanvas.setSizePolicy(self,
                                   QtGui.QSizePolicy.Expanding,
                                   QtGui.QSizePolicy.Expanding)
        FigureCanvas.updateGeometry(self)

a = QtGui.QApplication(sys.argv)
w = AppForm()
w.show()
a.exec_()
------------------------------------8<---------------------------------------