Hello list,

I am having some trouble with WTreeView widgets, and I am sure the problem is 
that I just don't understand the proper way to do things.  Here's the story...

We are trying to build a file selector dialog box to allow the user to select a 
file local to the server.  To do this, we read the file and directory names out 
of the "current" directory path, and use those to populate a WStandardItem 
model.  The WStandardItem model is attached to a WSortFilterProxyModel which is 
then attached to a WTreeView widget.  That part all works fine.  The files 
display properly in the WTreeView, the columns are sortable, the entries filter 
properly, and everything works just the way we want it to.  The problem comes 
when a user double-clicks on a directory entry.  At this point, we need to 
repopulate the model with the files and directories that live inside the 
directory just selected by the user.

My only prior experience with WStandardItem models is in connection with 
WCartesianChart widgets.  For my plotting applications, when it comes time to 
repopulate the model with different sets of plot data, I just call 
model->clear(), and add new rows, columns and series definitions as needed to 
contain the users newly selected data sets.  That all works just fine, and I 
assumed the process for this WTreeView application would be similar.  So, I 
assumed that when the time came to repopulate the model containing our file 
names with file names from a new directory, I could just call model->clear() on 
the WStandardItem model, and then add new rows and columns to the model to 
contain the new names.  But that doesn't work.  Instead, as soon as I call 
model->clear() the program crashes with a seg fault.  If instead, I instantiate 
a brand new WStandardItem model, populate it with the new file data, and then 
add that to the proxy model, that works fine.  But I figure that's probably not 
the way I'm supposed to be doing it.  For one thing, that leaves the memory 
used by the previous WStandardItem model still allocated.

So my question is, what is the correct way to clear out a model attached to a 
WTreeView (well, actually attached to a WSortFilterProxyModel that's attached 
to a WTreeView) and repopulate it?

I guess I should also mention I'm running this on Ubuntu 9.10 with some flavor 
of v3.0 Wt (it's a development revision from the git repository pulled a few 
days after v3.0 was released to pick up some bug fixes), using the wthttpd 
connector.

Any comments or suggestions will be most welcome.


Charlie Hubbard


------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to