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

Kubuntu 9.04:
Qt Open Source Edition 4.5.0
PyQt 4.4.4

Best regards

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.resize(700, 600)

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

        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)

a = QtGui.QApplication(sys.argv)
w = AppForm()