OK, so I spent most of my day trying to get asynchronous updates of a WTreeView 
to work and believe I finally have it working after making a fix to WTreeView.C.

Here is what I'm doing:

1.  I'm using a QFileSystemWatcher in its own thread (using libwtwithqt) to 
watch for file system changes
2.  I'm using another boost::thread that gets woken up whenever there is a 
directory change, this thread does a WApplication::lock() and 
WApplication::triggerUpdate().  In between the lock/update, it deletes the 
model of the WTreeView, sets it to a new one, populates it, and sets the expand 
depth as follows:

   
    WStandardItemModel *oldModel = mModel;
    mModel = new WStandardItemModel();

    mTreeView->setModel(mModel);
   
   
    populateBrowser();

   
    mTreeView->expandToDepth(4);

    if (mModel->rowCount() == 0)
    {
        WStandardItem *newItem = new WStandardItem("NO LOGS FOUND");
        newItem->setFlags(newItem->flags().clear(ItemIsSelectable));
        newItem->setIcon("icons/folder.gif");
        mModel->appendRow(newItem);
    }

    mApp->log("debug") << "LogFileBrowser::refreshLogs() - FINISH";

What was happening is that in expandToDepth(4) I was getting a bunch of these 
messages:

Comparing indexes from different models are you?
Comparing indexes from different models are you?
Comparing indexes from different models are you?
Comparing indexes from different models are you?
Comparing indexes from different models are you?
Comparing indexes from different models are you?
....

I believe what the problem is that this function gets called multiple times 
before a re-render happen, and thus WTreeView::rootNode_ does not get reset.  I 
modified WTreeView::setModel() to include:


  delete rootNode_;
  rootNode_ = NULL;

This seems to have fixed the problem. 

Note that prior to all this instead of deleting/creating a new model I tried 
doing mModel->clear() and then I got another problem which was an assert in 
WTreeView::modelRowsAboutToBeRemoved() (assert(w)).  I wonder if this is not 
related to the same problem?

Well, anyway, this is my first time really diving into the Wt src so it's 
possible I'm doing something wrong.  What do you guys think?


Daniel Ginsburg / email: [email protected]
Principal Software Architect
Fetal-Neonatal Neuroimaging and Development Science Center
Children's Hospital Boston
300 Longwood Avenue
Boston, MA 02115
Phone: 857-218-5140


------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to