[PyQt] Problem with a simple QDialog

Alexandre Badez alexandre.badez at gmail.com
Wed Nov 28 13:44:39 GMT 2007


On Nov 28, 2007 2:23 PM, Andreas Pakulat <apaku at gmx.de> wrote:

> On 28.11.07 13:21:37, Alexandre Badez wrote:
> > On Nov 28, 2007 12:00 PM, Andreas Pakulat <apaku at gmx.de> wrote:
> >
> > > But you can do this inside your dialog class. Just override the accept
> > > and reject methods and do whatever logic you have their.
> > >
> > > It doesn't make sense to have a modal dialog without another window
> > > (i.e. in your __main__ function), as then its not really modal. And
> > > making a modal dialog is exactly what the exec_() does.
> >
> > Exactly, but in this case, I need a modal dialog, that why I use the
> exec_.
>
> So you do have a QApplication created and executed already when you
> create your dialog?
>

Yes I do :)


>
> > My problem is what can make a "Bus Error" when I just simply want to
> create
> > a QDialog (even the simplest one).
>
> I don't know, google turns up a memory-corruption problem as first
> hit... Without some small self-contained example its hard to say what
> could be wrong.
>
> Andreas


That is my problem, and why I ask if somebody know anything about this.
Because, normaly it append after a memory leak (in C/C++ and others), but in
python we do not manage our memory that's my problem.


Ok, here is a bit more of my code.

It's in my own model:

    def addIndividu(self, index, lIndividu):
        self.beginRemoveRows(
            index,
            self.rowCount(index),
            self.rowCount(index))

        # We add the data in the node
        node = index.internalPointer()
        dProblem = node.addIndividu(lIndividu)

        if dProblem is not None and dProblem != {}:
            wChapterSelection =
WindowChapterSelectionDialog.WindowChapterSelectionDialog() # <- We create
an instance of the window

            # First we verify that all item have a valid type
            if dProblem.get('undefied_type') is not None:
                dUndef = dProblem.pop('undefied_type')
                for typeIndividu in dUndef:
                    lChapter = dUndef[typeIndividu][0]
                    lIndividu = dUndef[typeIndividu][1]

                    for individu in lIndividu:
                        wChapterSelection.setWindow(typeIndividu, individu,
lChapter)

                        wChapterSelection.exec_() # <- HERE IS MY PROBLEM !!
: "bus error"

                        if wChapterSelection.Accepted ==
wChapterSelection.result():
                            goodChapter = wChapterSelection.getSelection()
                            goodChapter.addIndividu([individu])


The problem is steel there if I do something like:

    def addIndividu(self, index, lIndividu):
        self.beginRemoveRows(
            index,
            self.rowCount(index),
            self.rowCount(index))

        # We add the data in the node
        node = index.internalPointer()
        dProblem = node.addIndividu(lIndividu)

        if dProblem is not None and dProblem != {}:
            wChapterSelection = QtgGui.QDialog() # <- We create an instance
of the window

            # First we verify that all item have a valid type
            if dProblem.get('undefied_type') is not None:
                dUndef = dProblem.pop('undefied_type')
                for typeIndividu in dUndef:
                    lChapter = dUndef[typeIndividu][0]
                    lIndividu = dUndef[typeIndividu][1]

                    for individu in lIndividu:
                        wChapterSelection.exec_() # <- HERE IS MY PROBLEM !!
: "bus error"

                        if wChapterSelection.Accepted ==
wChapterSelection.result():
                            print "ok :)"


Thanks for your help

-- 
Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20071128/dfebaaea/attachment.html


More information about the PyQt mailing list