PyGTK TreeView segmentation fault on expand_all()
I have recently begun a project using PyGTK, and part of my planned interface has a gtk.TreeView showing a portion of the filesystem. Now, rather than load the entire FS structure into the tree right from the beginning, I made a lazy tree by adding blank children to rows representing directories, and connected a call to fill in the data when a row with blank children was expanded.
Now, this works all fine and well, in general. I can browse my entire filesystem this way. But I noticed that hitting '*' (which I believe is a call to expand_all(), though the documentation does not say this explicitly) on a row representing any empty directory causes a segmentation fault. This problem can be alleviated by not removing the blank child after attempting to add directory contents, but I would like to avoid this approach. My suspicion is that expand_all() assumes that there are children present, and when I remove the blank row (after attempting to add any subdirectories and files), it does not check to make sure there are still children. So I suppose I have a couple questions. First, can anybody confirm my suspicions? Secondly, is this a PyGTK bug, or am I doing something that simply should never be done? Finally, do you see any way to fix this problem? Code:
def onExpand(self, view, iter, path): Thanks in advance, Chris |
In case anybody follows after, I solved this problem by connecting that function to both signals "test-expand-row" and "row-expanded". The former gets rid of the segfault problem by being run before expand_all() gets going too far, and the latter makes sure the blank children don't show.
A little bit hackish, but the upshot is that instead of expanding only one level on '*' and crashing with empty directories, we now expand two levels at a time and empty directories present no problems. |
All times are GMT -5. The time now is 02:15 PM. |