Hey, I'am new to pygtk and I'am wondering how subclassing is supposed to work. I did some classes, which derive from gtk.VBox, gobject.GObject, ... So far so good.
But I have a class, from which several Instanzes (in the extreme > 1000)
are created, which should be destroyed shortly afterwards. From looking
at top, I noticed, that the memory consumptions grows over time and here
the strange thing started.
I stripped my Class to it's skeleton and tested - and when calling the
pygtk Konstruktor, it prevents the objects from getting destroyed, after
the last reference goes out of scope.
With the attached class I get:
[EMAIL PROTECTED]:~/src/player-python$ python
Python 2.3.5 (#2, Nov 20 2005, 16:40:39)
[GCC 4.0.3 20051111 (prerelease) (Debian 4.0.2-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from test2 import Musikfile
>>> musik=Musikfile("u")
>>> musik=None
Musikfile destroyed
>>>
But without any surprise I can't call any gtk functions on it:
>>> musik.connect("error", test)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: object at 0xb7cf98ec of type Musikfile is not initialized
>>>
But when I comment in the superclass Konstruktor, the object isn't
destroyed:
[EMAIL PROTECTED]:~/src/player-python$ python
Python 2.3.5 (#2, Nov 20 2005, 16:40:39)
[GCC 4.0.3 20051111 (prerelease) (Debian 4.0.2-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from test2 import Musikfile
>>> musik=Musikfile("u")
>>> musik=None
>>>
You see, the Destructor isn't called! (It's the same when I subclass
from gobject.GObject, which I indeed did first)
Is there something wrong in my thoughts, am I overlooking something or
is there a bug hidden between these few lines?
Thanks
Matthias
--
Matthias Bläsing (GPG-Schlüsselkennung: A71B4BD5)
ICQ: 84617206 AIM: linuxfun81 MSN: [EMAIL PROTECTED]
#!/usr/bin/python
# -*- coding: UTF-8 -*-
#
#########################################################################################
#
# Musikfile
#
# Die Klasse hält für alle unterstützten Musikdateien jeweils einen Thread
# 1. zum einlesen bereit, um die Tag Informationen und die Länge zu extrahiern
# 2. zum Abspielen
import pygtk
pygtk.require('2.0')
import gobject
import gnomevfs
import gst
import gtk
import sys
class Musikfile(gtk.Object):
__gsignals__ = {
'completed_scanning': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'error': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,(gobject.TYPE_STRING,gobject.TYPE_STRING,))
}
def __init__(self, uri):
# gtk.Object.__init__(self)
pass
def __del__(*args):
print "Musikfile destroyed"
signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil
_______________________________________________ pygtk mailing list [email protected] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
