Re: [PyKDE] Double free() problem in PyQt 3.15.1??

2006-04-23 Thread Phil Thompson
On Saturday 22 April 2006 11:19 pm, Simon Edwards wrote:
 On Saturday 22 April 2006 21:17, Phil Thompson wrote:
  On Saturday 22 April 2006 4:04 pm, Simon Edwards wrote:
   I'm confused as to what the newer exec_loop() code in QDialog was meant
   to do.
   -
   %If (Qt_3_0_0 -)
 int exec() /PyName=exec_loop, ReleaseGIL,
 PreHook=__pyQtPreEventLoopHook__,
 PostHook=__pyQtPostEventLoopHook__/;
  
   It looks like it is meant to take ownership away from the parent dialog

 and

   let Python handle destruction of the popup. But the dumpObjectTree()
   lines in my test code say that the parent dialog always keeps the popup
   on it's list of children objects.
 
  Correct.
 
   When the parent dialog is destroyed so are the children objects. This
   is a problem if Python thinks that it should destroy the popup too.
 
  It's not a problem because QObject's dtor does the right thing in taking
  itself out of any parent's list of children. In other words, it doesn't
  matter (in the case of QObject and its subclasses) if both Python and C++
  think they should call the dtor.

 I think I follow what you are saying. But that is only going to work
 correctly in the case of Python and Qt wanting to destroy the child dialog
 if Python calls the d'tor first. If the child dialog is destroyed by Qt
 when the parent dialog is destroyed, and THEN Python comes along later
 wanting to destroy the child dialog again, then it goes wrong.

This shouldn't matter. The generated derived class that SIP creates 
(sipKDialogBase in the output below) contains a dtor that will be invoked 
when the parent destroys it's children. It resets the pointer to the C++ 
instance in the Python object (see sip_api_common_dtor() in siplib.c) so that 
when the Python object gets garbage collected it knows the C++ instance has 
already been destroyed and doesn't try and do it again.

Phil

 valgrind output suggests that this is what is happening. The parent dialog
 is destroyed. The child dialog is destroyed at the same time. And then
 Python tries the child again. valgrind says that the illegal free/delete is
 coming from Python itself. (the first stack trace below) And is refering to
 memory that was free'd via Qt (the second stack trace).

 ---
 Double QObject deletion detected.
 ==7997==
 ==7997== Invalid free() / delete / delete[]
 ==7997==at 0x401D268: operator delete(void*) (vg_replace_malloc.c:246)
 ==7997==by 0x4E22609: QObject::~QObject() (in
 /usr/lib/libqt-mt.so.3.3.6) ==7997==by 0x608452A: (within
 /usr/lib/python2.4/site-packages/kdeui.so) ==7997==by 0x402A927:
 (within /usr/lib/python2.4/site-packages/sip.so) ==7997==by 0x8089DDF:
 (within /usr/bin/python2.4)
 ==7997==by 0x80FA46D: (within /usr/bin/python2.4)
 ==7997==by 0x80B6FF5: PyEval_EvalFrame (in /usr/bin/python2.4)
 ==7997==by 0x80B76BE: PyEval_EvalCodeEx (in /usr/bin/python2.4)
 ==7997==by 0x80B7904: PyEval_EvalCode (in /usr/bin/python2.4)
 ==7997==by 0x80D946B: PyRun_FileExFlags (in /usr/bin/python2.4)
 ==7997==by 0x80D970B: PyRun_SimpleFileExFlags (in /usr/bin/python2.4)
 ==7997==by 0x8055B02: Py_Main (in /usr/bin/python2.4)
 ==7997==by 0x4080EA1: __libc_start_main
 (in /lib/tls/i686/cmov/libc-2.3.6.so)


 ==7997==  Address 0x56CFFE0 is 0 bytes inside a block of size 2,044 free'd
 ==7997==at 0x401D268: operator delete(void*) (vg_replace_malloc.c:246)
 ==7997==by 0x6073D6B: sipKDialogBase::~sipKDialogBase()
 (in /usr/lib/python2.4/site-packages/kdeui.so)
 ==7997==by 0x608452A: (within
 /usr/lib/python2.4/site-packages/kdeui.so) ==7997==by 0x402A927:
 (within /usr/lib/python2.4/site-packages/sip.so) ==7997==by 0x8089DDF:
 (within /usr/bin/python2.4)
 ==7997==by 0x80FC987: (within /usr/bin/python2.4)
 ==7997==by 0x4029030: (within /usr/lib/python2.4/site-packages/sip.so)
 ==7997==by 0x607840C: sipKDialogBase::removeChild(QObject*)
 (in /usr/lib/python2.4/site-packages/kdeui.so)
 ==7997==by 0x4E22AA8: QObject::~QObject() (in
 /usr/lib/libqt-mt.so.3.3.6) ==7997==by 0x4E5D05C: QWidget::~QWidget()
 (in /usr/lib/libqt-mt.so.3.3.6) ==7997==by 0x4FD7A07:
 QDialog::~QDialog() (in /usr/lib/libqt-mt.so.3.3.6) ==7997==by
 0x4916B05: sipQDialog::~sipQDialog()
 (in /usr/lib/python2.4/site-packages/qt.so)
 ==7997==by 0x491DF56: (within /usr/lib/python2.4/site-packages/qt.so)
 ==7997==by 0x402A927: (within /usr/lib/python2.4/site-packages/sip.so)
 ==7997==by 0x8089DDF: (within /usr/bin/python2.4)
 ==7997==by 0x807A2D4: (within /usr/bin/python2.4)
 ==7997==by 0x402A8A4: (within /usr/lib/python2.4/site-packages/sip.so)
 ==7997==by 0x402A8E0: (within /usr/lib/python2.4/site-packages/sip.so)
 ==7997==by 0x8089DDF: (within /usr/bin/python2.4)
 ==7997==by 0x80FA46D: (within /usr/bin/python2.4)
 ==7997==by 0x80B6FF5: PyEval_EvalFrame (in 

Re: [PyKDE] Double free() problem in PyQt 3.15.1??

2006-04-22 Thread Simon Edwards

Hello,

I've spent some more time playing with this problem some more. (See 
attachment). I've added some dumpObjectTree() calls and debug for the __del__ 
methods for the two dialogs. To me it clears looks like SIP and Python 
disagree about who is responsible for destroying the popup dialog. The 
__del__ method for the popup is called two times.

I'm confused as to what the newer exec_loop() code in QDialog was meant to do. 

-
%If (Qt_3_0_0 -)
int exec() /PyName=exec_loop, ReleaseGIL,
PreHook=__pyQtPreEventLoopHook__,
PostHook=__pyQtPostEventLoopHook__/;
%MethodCode
// Transfer ownership back to Python (a modal dialog will
// probably have the main window as it's parent).  This means
// the Qt dialog will be deleted when the Python wrapper is
// garbage collected.  Although this is a little inconsistent,
// it saves having to code it explicitly to avoid the memory
// leak.
sipTransferBack(sipSelf);

Py_BEGIN_ALLOW_THREADS
sipRes = sipCpp-QDialog::exec();
Py_END_ALLOW_THREADS
%End
%End
---

It looks like it is meant to take ownership away from the parent dialog and 
let Python handle destruction of the popup. But the dumpObjectTree() lines in 
my test code say that the parent dialog always keeps the popup on it's list 
of children objects.

When the parent dialog is destroyed so are the children objects. This is a 
problem if Python thinks that it should destroy the popup too.

I can't explain why Phil's Qt only examples does not fail like the KDE 
version. :-/

It is possible to work around this problem by explicitly calling 
QDialog.removeChild() to remove the popup from the parent dialog's list of 
children.

cheers,


On Sunday 12 March 2006 18:48, Jim Bublitz wrote:
 On Sunday 12 March 2006 07:04, Phil Thompson wrote:
  On Sunday 12 March 2006 10:04 am, Simon Edwards wrote:
   On Saturday 11 March 2006 20:26, Phil Thompson wrote:
On Saturday 11 March 2006 7:13 pm, Simon Edwards wrote:
 Anyway, I think I've come across a double free memory bug in PyQt
 3.15.1. Qt complains about a Double QObject deletion detected., 
and
 valgrind points to a problem in sipKDialogBase::~sipKDialogBase().
 (Reading memory which is already free'd, and invalid free(), delete
 etc). This problem
  
   only
  
 appears when my app opens a dialog.

-- 
Simon Edwards             | KDE-NL, Guidance tools, Guarddog Firewall
[EMAIL PROTECTED]       | http://www.simonzone.com/software/
Nijmegen, The Netherlands | ZooTV? You made the right choice.


qdialogdoublefree2.py
Description: application/python
___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] Double free() problem in PyQt 3.15.1??

2006-04-22 Thread Phil Thompson
On Saturday 22 April 2006 4:04 pm, Simon Edwards wrote:
 Hello,

 I've spent some more time playing with this problem some more. (See
 attachment). I've added some dumpObjectTree() calls and debug for the
 __del__ methods for the two dialogs. To me it clears looks like SIP and
 Python disagree about who is responsible for destroying the popup dialog.
 The __del__ method for the popup is called two times.

 I'm confused as to what the newer exec_loop() code in QDialog was meant to
 do.

 -
 %If (Qt_3_0_0 -)
   int exec() /PyName=exec_loop, ReleaseGIL,
   PreHook=__pyQtPreEventLoopHook__,
   PostHook=__pyQtPostEventLoopHook__/;
 %MethodCode
   // Transfer ownership back to Python (a modal dialog will
   // probably have the main window as it's parent).  This means
   // the Qt dialog will be deleted when the Python wrapper is
   // garbage collected.  Although this is a little inconsistent,
   // it saves having to code it explicitly to avoid the memory
   // leak.
   sipTransferBack(sipSelf);

   Py_BEGIN_ALLOW_THREADS
   sipRes = sipCpp-QDialog::exec();
   Py_END_ALLOW_THREADS
 %End
 %End
 ---

 It looks like it is meant to take ownership away from the parent dialog and
 let Python handle destruction of the popup. But the dumpObjectTree() lines
 in my test code say that the parent dialog always keeps the popup on it's
 list of children objects.

Correct.

 When the parent dialog is destroyed so are the children objects. This is a
 problem if Python thinks that it should destroy the popup too.

It's not a problem because QObject's dtor does the right thing in taking 
itself out of any parent's list of children. In other words, it doesn't 
matter (in the case of QObject and its subclasses) if both Python and C++ 
think they should call the dtor.

 I can't explain why Phil's Qt only examples does not fail like the KDE
 version. :-/

 It is possible to work around this problem by explicitly calling
 QDialog.removeChild() to remove the popup from the parent dialog's list of
 children.

The whole point was to avoid extra coding like this - which a lot of people 
wouldn't realise was necessary.

Phil

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] Double free() problem in PyQt 3.15.1??

2006-04-22 Thread Simon Edwards
On Saturday 22 April 2006 21:17, Phil Thompson wrote:
 On Saturday 22 April 2006 4:04 pm, Simon Edwards wrote:
  I'm confused as to what the newer exec_loop() code in QDialog was meant to
  do.
  -
  %If (Qt_3_0_0 -)
  int exec() /PyName=exec_loop, ReleaseGIL,
  PreHook=__pyQtPreEventLoopHook__,
  PostHook=__pyQtPostEventLoopHook__/;

  It looks like it is meant to take ownership away from the parent dialog 
and
  let Python handle destruction of the popup. But the dumpObjectTree() lines
  in my test code say that the parent dialog always keeps the popup on it's
  list of children objects.
 Correct.
  When the parent dialog is destroyed so are the children objects. This is a
  problem if Python thinks that it should destroy the popup too.
 
 It's not a problem because QObject's dtor does the right thing in taking 
 itself out of any parent's list of children. In other words, it doesn't 
 matter (in the case of QObject and its subclasses) if both Python and C++ 
 think they should call the dtor.

I think I follow what you are saying. But that is only going to work correctly 
in the case of Python and Qt wanting to destroy the child dialog if Python 
calls the d'tor first. If the child dialog is destroyed by Qt when the parent 
dialog is destroyed, and THEN Python comes along later wanting to destroy the 
child dialog again, then it goes wrong.

valgrind output suggests that this is what is happening. The parent dialog is 
destroyed. The child dialog is destroyed at the same time. And then Python 
tries the child again. valgrind says that the illegal free/delete is coming 
from Python itself. (the first stack trace below) And is refering to memory 
that was free'd via Qt (the second stack trace).

---
Double QObject deletion detected.
==7997==
==7997== Invalid free() / delete / delete[]
==7997==at 0x401D268: operator delete(void*) (vg_replace_malloc.c:246)
==7997==by 0x4E22609: QObject::~QObject() (in /usr/lib/libqt-mt.so.3.3.6)
==7997==by 0x608452A: (within /usr/lib/python2.4/site-packages/kdeui.so)
==7997==by 0x402A927: (within /usr/lib/python2.4/site-packages/sip.so)
==7997==by 0x8089DDF: (within /usr/bin/python2.4)
==7997==by 0x80FA46D: (within /usr/bin/python2.4)
==7997==by 0x80B6FF5: PyEval_EvalFrame (in /usr/bin/python2.4)
==7997==by 0x80B76BE: PyEval_EvalCodeEx (in /usr/bin/python2.4)
==7997==by 0x80B7904: PyEval_EvalCode (in /usr/bin/python2.4)
==7997==by 0x80D946B: PyRun_FileExFlags (in /usr/bin/python2.4)
==7997==by 0x80D970B: PyRun_SimpleFileExFlags (in /usr/bin/python2.4)
==7997==by 0x8055B02: Py_Main (in /usr/bin/python2.4)
==7997==by 0x4080EA1: __libc_start_main 
(in /lib/tls/i686/cmov/libc-2.3.6.so)


==7997==  Address 0x56CFFE0 is 0 bytes inside a block of size 2,044 free'd
==7997==at 0x401D268: operator delete(void*) (vg_replace_malloc.c:246)
==7997==by 0x6073D6B: sipKDialogBase::~sipKDialogBase() 
(in /usr/lib/python2.4/site-packages/kdeui.so)
==7997==by 0x608452A: (within /usr/lib/python2.4/site-packages/kdeui.so)
==7997==by 0x402A927: (within /usr/lib/python2.4/site-packages/sip.so)
==7997==by 0x8089DDF: (within /usr/bin/python2.4)
==7997==by 0x80FC987: (within /usr/bin/python2.4)
==7997==by 0x4029030: (within /usr/lib/python2.4/site-packages/sip.so)
==7997==by 0x607840C: sipKDialogBase::removeChild(QObject*) 
(in /usr/lib/python2.4/site-packages/kdeui.so)
==7997==by 0x4E22AA8: QObject::~QObject() (in /usr/lib/libqt-mt.so.3.3.6)
==7997==by 0x4E5D05C: QWidget::~QWidget() (in /usr/lib/libqt-mt.so.3.3.6)
==7997==by 0x4FD7A07: QDialog::~QDialog() (in /usr/lib/libqt-mt.so.3.3.6)
==7997==by 0x4916B05: sipQDialog::~sipQDialog() 
(in /usr/lib/python2.4/site-packages/qt.so)
==7997==by 0x491DF56: (within /usr/lib/python2.4/site-packages/qt.so)
==7997==by 0x402A927: (within /usr/lib/python2.4/site-packages/sip.so)
==7997==by 0x8089DDF: (within /usr/bin/python2.4)
==7997==by 0x807A2D4: (within /usr/bin/python2.4)
==7997==by 0x402A8A4: (within /usr/lib/python2.4/site-packages/sip.so)
==7997==by 0x402A8E0: (within /usr/lib/python2.4/site-packages/sip.so)
==7997==by 0x8089DDF: (within /usr/bin/python2.4)
==7997==by 0x80FA46D: (within /usr/bin/python2.4)
==7997==by 0x80B6FF5: PyEval_EvalFrame (in /usr/bin/python2.4)
==7997==by 0x80B76BE: PyEval_EvalCodeEx (in /usr/bin/python2.4)
==7997==by 0x80B7904: PyEval_EvalCode (in /usr/bin/python2.4)
==7997==by 0x80D946B: PyRun_FileExFlags (in /usr/bin/python2.4)
==7997==by 0x80D970B: PyRun_SimpleFileExFlags (in /usr/bin/python2.4)
==7997==by 0x8055B02: Py_Main (in /usr/bin/python2.4)
==7997==by 0x4080EA1: __libc_start_main 
(in /lib/tls/i686/cmov/libc-2.3.6.so)
---


-- 
Simon Edwards             | KDE-NL, Guidance tools, Guarddog Firewall

Re: [PyKDE] Double free() problem in PyQt 3.15.1??

2006-03-12 Thread Simon Edwards
On Saturday 11 March 2006 20:26, Phil Thompson wrote:
 On Saturday 11 March 2006 7:13 pm, Simon Edwards wrote:
  Anyway, I think I've come across a double free memory bug in PyQt 3.15.1.
  Qt complains about a Double QObject deletion detected., and valgrind
  points to a problem in sipKDialogBase::~sipKDialogBase(). (Reading memory
  which is already free'd, and invalid free(), delete etc). This problem 
only
  appears when my app opens a dialog.

OK, I've chopped my code right down See attachment. Running this on the 
current Kubuntu Dapper shows this in the console:

[EMAIL PROTECTED]:~$ python ./qdialogdoublefree.py
kbuildsycoca running...
Double QObject deletion detected.
*** glibc detected *** double free or corruption (!prev): 0x082cfa40 ***
KCrash: Application 'qdialogdoublefree.py' crashing...
[EMAIL PROTECTED]:~$ 

Using show() instead of exec_loop() does in fact _not_ trigger the problem.

Here is some more version info:

Package: python2.4-qt3
Architecture: i386
Version: 3.15.1-0ubuntu3

Package: python2.4-kde3
Architecture: i386
Version: 3.11.4+snapshot20051013-0ubuntu5

Package: python2.4-sip4-qt3
Architecture: i386
Version: 4.3.2-0ubuntu2

Package: g++
Architecture: i386
Version: 4:4.0.2-3


cheers,

-- 
Simon Edwards             | KDE-NL, Guidance tools, Guarddog Firewall
[EMAIL PROTECTED]       | http://www.simonzone.com/software/
Nijmegen, The Netherlands | ZooTV? You made the right choice.


qdialogdoublefree.py
Description: application/python
___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] Double free() problem in PyQt 3.15.1??

2006-03-12 Thread Phil Thompson
On Sunday 12 March 2006 10:04 am, Simon Edwards wrote:
 On Saturday 11 March 2006 20:26, Phil Thompson wrote:
  On Saturday 11 March 2006 7:13 pm, Simon Edwards wrote:
   Anyway, I think I've come across a double free memory bug in PyQt
   3.15.1. Qt complains about a Double QObject deletion detected., and
   valgrind points to a problem in sipKDialogBase::~sipKDialogBase().
   (Reading memory which is already free'd, and invalid free(), delete
   etc). This problem

 only

   appears when my app opens a dialog.

 OK, I've chopped my code right down See attachment. Running this on the
 current Kubuntu Dapper shows this in the console:

 [EMAIL PROTECTED]:~$ python ./qdialogdoublefree.py
 kbuildsycoca running...
 Double QObject deletion detected.
 *** glibc detected *** double free or corruption (!prev): 0x082cfa40 ***
 KCrash: Application 'qdialogdoublefree.py' crashing...
 [EMAIL PROTECTED]:~$

 Using show() instead of exec_loop() does in fact _not_ trigger the problem.

Attached is a PyQt only version which doesn't seem to have a problem (have I 
removed too much?). This is using latest snapshots.

Phil


qdialogdoublefree.py
Description: application/python
___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] Double free() problem in PyQt 3.15.1??

2006-03-12 Thread Jim Bublitz
On Sunday 12 March 2006 07:04, Phil Thompson wrote:
 On Sunday 12 March 2006 10:04 am, Simon Edwards wrote:
  On Saturday 11 March 2006 20:26, Phil Thompson wrote:
   On Saturday 11 March 2006 7:13 pm, Simon Edwards wrote:
Anyway, I think I've come across a double free memory bug in PyQt
3.15.1. Qt complains about a Double QObject deletion detected., and
valgrind points to a problem in sipKDialogBase::~sipKDialogBase().
(Reading memory which is already free'd, and invalid free(), delete
etc). This problem
 
  only
 
appears when my app opens a dialog.
 
  OK, I've chopped my code right down See attachment. Running this on the
  current Kubuntu Dapper shows this in the console:
 
  [EMAIL PROTECTED]:~$ python ./qdialogdoublefree.py
  kbuildsycoca running...
  Double QObject deletion detected.
  *** glibc detected *** double free or corruption (!prev): 0x082cfa40 ***
  KCrash: Application 'qdialogdoublefree.py' crashing...
  [EMAIL PROTECTED]:~$
 
  Using show() instead of exec_loop() does in fact _not_ trigger the
  problem.

 Attached is a PyQt only version which doesn't seem to have a problem (have
 I removed too much?). This is using latest snapshots.

On a 1/10 PyQt snapshot I get:

*** glibc detected *** double free or corruption (!prev): 0x081fc950 ***
Alarm clock

when I close the application, but only if the QDialog has been instantiated at 
least once (by pushing the button).  It works fine until I close the 
application. I don't know where the Alarm clock is coming from - a SIGALRM 
someplace? I don't get the Qt error or KCrash though.

I get the same thing if I create a main window and run KApplication's event 
loop and then instantiate the KDialogBase object with the main window as its 
parent. In that case,  the double free is happening before 
QApplication.quit() is called from lastWindowClosed (and KApplication uses 
QApplication's quit())

However, if I make UserEditDialog parentless (pass None instead of self - 
where self would be the KDialogBase obj), it works fine (as provided by 
Simon or with the KMainWindow).

Jim

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] Double free() problem in PyQt 3.15.1??

2006-03-11 Thread Phil Thompson
On Saturday 11 March 2006 7:13 pm, Simon Edwards wrote:
 Hi Phil and everybody else,

 I'm busy working on polishing and debugging stuff for the coming Kubuntu
 release, which makes increasingly more use of PyQt+PyKDE BTW.

 Anyway, I think I've come across a double free memory bug in PyQt 3.15.1.
 Qt complains about a Double QObject deletion detected., and valgrind
 points to a problem in sipKDialogBase::~sipKDialogBase(). (Reading memory
 which is already free'd, and invalid free(), delete etc). This problem only
 appears when my app opens a dialog.

Opens it? Or when the name goes out of scope?

 This problem does not occur with PyQt 3.14.1. Comparing the two PyQt
 releases I see this added to the 3.15.1 qdialog.sip:

 -
 %If (- Qt_3_0_0)
   int exec() /PyName=exec_loop, ReleaseGIL,
   PreHook=__pyQtPreEventLoopHook__,
   PostHook=__pyQtPostEventLoopHook__/;
 %MethodCode
   // Transfer ownership back to Python (a modal dialog will
   // probably have the main window as it's parent).  This means
   // the Qt dialog will be deleted when the Python wrapper is
   // garbage collected.  Although this is a little inconsistent,
   // it saves having to code it explicitly to avoid the memory
   // leak.
   sipTransferBack(sipSelf);

   Py_BEGIN_ALLOW_THREADS
   sipRes = sipCpp-QDialog::exec();
   Py_END_ALLOW_THREADS
 %End
 %End
 -

 This does look like it could be the problem. Phil?

Possibly. How are you constructing the dialog? Does it have a parent? Are the 
references to it local or global?

Phil

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] Double free() problem in PyQt 3.15.1??

2006-03-11 Thread Giovanni Bajo
Simon Edwards [EMAIL PROTECTED] wrote:

 Anyway, I think I've come across a double free memory bug in PyQt 3.15.1.
Qt
 complains about a Double QObject deletion detected., and valgrind points
 to a problem in sipKDialogBase::~sipKDialogBase(). (Reading memory which
is
 already free'd, and invalid free(), delete etc). This problem only appears
 when my app opens a dialog.

 This problem does not occur with PyQt 3.14.1. Comparing the two PyQt
 releases I see this added to the 3.15.1 qdialog.sip:

 -
 %If (- Qt_3_0_0)
 int exec() /PyName=exec_loop, ReleaseGIL,
 PreHook=__pyQtPreEventLoopHook__,
 PostHook=__pyQtPostEventLoopHook__/;
 %MethodCode
 // Transfer ownership back to Python (a modal dialog will
 // probably have the main window as it's parent).  This means
 // the Qt dialog will be deleted when the Python wrapper is
 // garbage collected.  Although this is a little inconsistent,
 // it saves having to code it explicitly to avoid the memory
 // leak.
 sipTransferBack(sipSelf);

 Py_BEGIN_ALLOW_THREADS
 sipRes = sipCpp-QDialog::exec();
 Py_END_ALLOW_THREADS
 %End
 %End
 -

 This does look like it could be the problem. Phil?


Do you have a sample source code which shows the crash? That call to
sipTransferBack is actually very important to properly avoid memory leak, so
I'm curious how it could trigger a double deletion. Notice that there are
some way to make PyQt crash with double deletion, such as:

=
from qt import *

app = QApplication([])
w1 = QWidget(None)
w2 = QWidget(w1)
w2. = w1
w2.deleteLater()

del w1
del w2

app.processEvents()
=

but they have nothing to do with the code you quoted.
-- 
Giovanni Bajo

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] Double free() problem in PyQt 3.15.1??

2006-03-11 Thread Jim Bublitz
On Saturday 11 March 2006 11:13, Simon Edwards wrote:
 Hi Phil and everybody else,

 I'm busy working on polishing and debugging stuff for the coming Kubuntu
 release, which makes increasingly more use of PyQt+PyKDE BTW.

 Anyway, I think I've come across a double free memory bug in PyQt 3.15.1.
 Qt complains about a Double QObject deletion detected., and valgrind
 points to a problem in sipKDialogBase::~sipKDialogBase(). (Reading memory
 which is already free'd, and invalid free(), delete etc). This problem only
 appears when my app opens a dialog.

 This problem does not occur with PyQt 3.14.1. Comparing the two PyQt
 releases I see this added to the 3.15.1 qdialog.sip:

 -
 %If (- Qt_3_0_0)
   int exec() /PyName=exec_loop, ReleaseGIL,
   PreHook=__pyQtPreEventLoopHook__,
   PostHook=__pyQtPostEventLoopHook__/;
 %MethodCode
   // Transfer ownership back to Python (a modal dialog will
   // probably have the main window as it's parent).  This means
   // the Qt dialog will be deleted when the Python wrapper is
   // garbage collected.  Although this is a little inconsistent,
   // it saves having to code it explicitly to avoid the memory
   // leak.
   sipTransferBack(sipSelf);

   Py_BEGIN_ALLOW_THREADS
   sipRes = sipCpp-QDialog::exec();
   Py_END_ALLOW_THREADS
 %End
 %End
 -

 This does look like it could be the problem. Phil?

That code is only compiled for Qt  3.0.0; the code for Qt = 3.0.0 is a 
little farther down in the sip file:

%If (Qt_3_0_0 -)
int exec() /PyName=exec_loop, ReleaseGIL,
PreHook=__pyQtPreEventLoopHook__,
PostHook=__pyQtPostEventLoopHook__/;
%End

PyKDE/examples/uisampler.py has a KDailogBase example. It uses show() instead 
of exec_loop() as shipped, but it works using exec_loop() as well with recent 
sip/PyQt snapshots (newer than 3.15). I don't have a 3.15.x version running I 
can test it with.

However there are a lot of variables in what child widgets KDialogBase 
actually constructs, and the problem might be with one of those, so a 
specific example would be helpful.

Jim


___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde