tag:blogger.com,1999:blog-1978356510587112308.post7019191687940810927..comments2024-02-27T21:15:04.267+13:00Comments on Aligorith's Lair: PyGTK - DrawingArea, Notebook Tabs, and DeadlocksUnknownnoreply@blogger.comBlogger1125tag:blogger.com,1999:blog-1978356510587112308.post-26180226379007763302012-03-16T11:13:27.389+13:002012-03-16T11:13:27.389+13:00Hello Aligorith
It's been a while I haven'...Hello Aligorith<br /><br />It's been a while I haven't looked at PyGTK, although I think that it's abandonned in favor of GObject introspection.<br /><br />Anyway, from my experience, even though I think the GTK API is annoying, verbosive etc... it did work in the end (but I finally switched to Qt for other reasons).<br /><br />I think you are stacking layers of potential errors. Firstly, Python has it's ways of doing things that doesn't always play well with the C objects it wraps (each object has two face : the Python face and the C face and, for example, it can occur that one of them gets deleted and not the other -> crash). You also add reference counting that can prevent proper deletions (use weakrefs).<br /><br />Secondly, threading an application can be a headache. Threading a graphical application is even worse (take care never to create a widget out of the main thread, use events to communicate from secondary thread to main thread).<br /><br />You're mixing both so it can become touchy! I don't know how you work, but here's what I'd do:<br /> - in "A references B and B back-references A" situations, if A doesn't strictly need B to live, make the back reference a weak reference.<br /> - as a general rule, if you can use a weak ref instead of a strong ref in a complex system, then use the weak ref.<br /> - all widgets in main thread<br /> - "loose coupled communication" == signal based communication from non-main threads (simply puts a new event on the event loop of the main thread which is then directed to the correct widget)<br /><br />I also experienced some issues with __del__ methods. In the end I removed all of them. If I remember well, in some situations they prevent proper deletion of the objects that implement them. They are also bad for inheritance.<br /><br />These are my ideas, and sorry, no I don't know any good static analyser that could help for this :). However, I use GDB to debug programs which mix Python and C[++] and it turns out to be just enough for me.<br /><br />Danieldanihttps://www.blogger.com/profile/15168978540650615465noreply@blogger.com