aync Wt::WAbstractItemModel feeding Chart::WCartesianChart outside of WApplication
Added by Ray . over 4 years ago
I have a customized Wt::WAbstractItemModel which accepts data from some asynchronous system events. That is, it is not a component within a WApplication but actually lives in a class inherited from WServer.
An WApplication instance accesses the model via WEnvironment passed into the WApplication.
The model generates endInsertRows signals which percolate through and finally call WWidget::scheduleRerender, which calls WApplication::instance() at line 125. And as the model is resident outside of an instance, that lookup seg faults.
Any suggestions on how best to run a Wt::WAbstractItemModel outside of any particular WApplication, so that it might feed multiple WApplication instances?
Replies (2)
RE: aync Wt::WAbstractItemModel feeding Chart::WCartesianChart outside of WApplication - Added by Roel Standaert over 4 years ago
The short answer is that you can't. Since models update views and charts using Wt signals, and Wt's signals are not thread safe, you can not share a model between different WApplications like that.
I guess you could make a WAbstractItemModel
per WApplication that fetches its data in a thread safe manner from a shared model, and any notifications of changes can be done through WServer::post or WServer::postAll, but Wt itself does not have any ready-made solution for that.
RE: aync Wt::WAbstractItemModel feeding Chart::WCartesianChart outside of WApplication - Added by Ray . over 4 years ago
Ok, thank you. I had done pretty much what you had suggested as an alternative.