On 5/9/07, Jan Hudec <bulb@xxxxxx> wrote:
On Wed, May 09, 2007 at 23:09:25 +0200, Fredrik Kuivinen wrote: > I have used PyQt for some smaller projects (notably Hgct, a no longer > developed > commit tool for git and Mercurial. See > http://repo.or.cz/w/hgct.git?a=tree). For me > PyQt has worked very well. The python interface to Qt is more or less a > direct > translation of the C++ interface, so the excellent documentation troll > tech provides > for Qt can be used when developing with PyQt as well. > > I have never seen the segfaulting you mention. Maybe my programs have been > too > small to trigger that bug... It's not about size of the programs. It's about having to be careful not to refer to widgets inside eg. dialog box from outside and close that dialog box.
In Qt all the classes that ineriths from QObject are memory managed, to be more clear you can say that one class is "child" of another class (always ineritherd from QObject) that becames the parent. When you delete the parent, all his children are deleted too, this is a (big) feature to avoid missing free() calls for resources created with mallocs() , (well, in C++ we say 'delete' for resources created by 'new' but the concept is more or less the same). Note that this property can be nested: create a main window, inside a window there is a tab form, inside the tab there is a list view, inside the list view there are items (lines of list view). So *when* you delete the main window all this stuff is automatically deleted by Qt. It is diffrent from a garbage collector because there is no delay in releasing memory and all the thing is strict deterministic. So coming to your problem, if you need to refer to a widget inside a dialog *after* the dialog has been deleted you can simply reparent to NULL the widget before closing the dialog so to remove your object from the delete list of the dialog. Another option, in case your obect is not a graphical widget, is to avoid declaring your object "child" of the dialog in first instance setting his parent to NULL. This is clearly better because documents 'in code' also the real relationship between the dialog and your object. Marco - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html