[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] Problem with a simple QDialog
From:       "Alexandre Badez" <alexandre.badez () gmail ! com>
Date:       2007-11-28 13:44:39
Message-ID: 20f595e90711280544k27432385m1c1f697560500906 () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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

> On 28.11.07 13:21:37, Alexandre Badez wrote:
> > On Nov 28, 2007 12:00 PM, Andreas Pakulat <apaku@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

[Attachment #5 (text/html)]

On Nov 28, 2007 2:23 PM, Andreas Pakulat &lt;<a \
href="mailto:apaku@gmx.de">apaku@gmx.de</a>&gt; wrote:<br><div \
class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid \
rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> <div \
class="Ih2E3d">On 28.11.07 13:21:37, Alexandre Badez wrote:<br>&gt; On Nov 28, 2007 \
12:00 PM, Andreas Pakulat &lt;<a href="mailto:apaku@gmx.de">apaku@gmx.de</a>&gt; \
wrote:<br>&gt;<br>&gt; &gt; But you can do this inside your dialog class. Just \
override the accept <br>&gt; &gt; and reject methods and do whatever logic you have \
their.<br>&gt; &gt;<br>&gt; &gt; It doesn&#39;t make sense to have a modal dialog \
without another window<br>&gt; &gt; (i.e. in your __main__ function), as then its not \
really modal. And <br>&gt; &gt; making a modal dialog is exactly what the exec_() \
does.<br>&gt;<br></div><div class="Ih2E3d">&gt; Exactly, but in this case, I need a \
modal dialog, that why I use the exec_.<br><br></div>So you do have a QApplication \
created and executed already when you <br>create your dialog?<br><div \
class="Ih2E3d"></div></blockquote><div><br>Yes I do :)<br>&nbsp;</div><blockquote \
class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt \
0pt 0.8ex; padding-left: 1ex;"> <div class="Ih2E3d"><br>&gt; My problem is what can \
make a &quot;Bus Error&quot; when I just simply want to create<br>&gt; a QDialog \
(even the simplest one).<br><br></div>I don&#39;t know, google turns up a \
memory-corruption problem as first <br>hit... Without some small self-contained \
example its hard to say what<br>could be wrong.<br><br>Andreas<font \
color="#888888"></font></blockquote><div><br>That is my problem, and why I ask if \
somebody know anything about this. <br>Because, normaly it append after a memory leak \
(in C/C++ and others), but in python we do not manage our memory that&#39;s my \
problem.<br><br><br>Ok, here is a bit more of my code.<br><br>It&#39;s in my own \
model:<br> <br>&nbsp;&nbsp;&nbsp; def addIndividu(self, index, \
lIndividu):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
self.beginRemoveRows(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
index,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
self.rowCount(index),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
self.rowCount(index))<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # We add the \
data in the node <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; node = \
index.internalPointer()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dProblem = \
node.addIndividu(lIndividu)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if dProblem is not None and dProblem \
!= {}:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
wChapterSelection = WindowChapterSelectionDialog.WindowChapterSelectionDialog () # \
&lt;- We create an instance of the \
window<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # \
First we verify that all item have a valid \
type<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if \
dProblem.get(&#39;undefied_type&#39;) is not \
None:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
dUndef = dProblem.pop \
(&#39;undefied_type&#39;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
for typeIndividu in dUndef:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
lChapter = dUndef[typeIndividu][0]<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
lIndividu = dUndef[typeIndividu][1]<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
for individu in lIndividu:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
wChapterSelection.setWindow(typeIndividu, individu, \
lChapter)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
wChapterSelection.exec_() # &lt;- HERE IS MY PROBLEM !! : &quot;bus error&quot; \
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
if wChapterSelection.Accepted == \
wChapterSelection.result():<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& \
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
goodChapter = wChapterSelection.getSelection()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
 goodChapter.addIndividu([individu])<br></div></div><br><br>The problem is steel \
there if I do something like:<br><br>&nbsp;&nbsp;&nbsp; def addIndividu(self, index, \
lIndividu):<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.beginRemoveRows(<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; index,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
self.rowCount(index),<br> \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
self.rowCount(index))<br> <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # We add the data in the node<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; node = index.internalPointer()<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dProblem = node.addIndividu(lIndividu)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if dProblem is not None and dProblem != \
{}:<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
wChapterSelection = QtgGui.QDialog() # &lt;- We
create an instance of the window<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # First we verify \
that all item have a valid type<br> \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if \
dProblem.get(&#39;undefied_type&#39;) is not None:<br> \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
dUndef = dProblem.pop(&#39;undefied_type&#39;)<br> \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
for typeIndividu in dUndef:<br> \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
lChapter = dUndef[typeIndividu][0]<br> \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
lIndividu = dUndef[typeIndividu][1]<br> \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
for individu in lIndividu:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
wChapterSelection.exec_() # &lt;- HERE IS MY PROBLEM !! : &quot;bus error&quot;<br> \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
if wChapterSelection.Accepted == wChapterSelection.result():<br> \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
print &quot;ok :)&quot;<br><br><br>Thanks for your help<br><br>-- <br>Alex<br>



_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic