# try to leak memory
from Qt.Core import QObject, childrens, factory



print
print 'Test #1: parentless QObjects'
for i in range(3):
    a = QObject()
    a.objectName = 'a'+str(i)
    print 'creating a'+str(i), a

    
a = QObject()
a.objectName = 'a'
c = QObject(a)
#a.__children__ = []

print
print 'Test #2: parented QObjects'
print a, c
for i in range(3):
    b = QObject(a)
    #a.__children__.append(b)
    b.objectName = 'b'+str(i)
    print 'creating b'+str(i), b
    #c = factory(a)
    #print c
#del b
c.setParent(None)
# parent test

from Qt.Core import QObject
from Qt.Gui import QApplication, QPushButton

app = QApplication('app')
button = QPushButton('Push me', None)
a = QObject(button)
a.objectName = 'a'
button.objectName = 'button'

print button, a, a.parent()
print type(button), type(a), type(a.parent())
print button == a.parent()
for obj in [a, button, a.parent()]:
    print obj.objectName, obj