Hi all,
In our application we have some realtime plotting (using
Wt::Chart::WCartesianChart), when our application
decide to plot something is uses a method plot of our class WtTerminal::plot.
WtTerminal::plot does (more or less):
Wt::WStandardItemModel* myDataModelBuffer = new Wt::WStandardItemModel(...)
Wt::WServer::instance()->post(theSessionId,
boost::bind(&WtTerminal::swapModel,
this,
myDataModelBuffer));
WtTerminal has inside a pointer to the chart and the method swapModel
uses the setModel on the chart,
deleting the old one.
The problem arises when the instance of WtTerminal is destroyed and
there are still pending posts.
What we plan to do is to put in queue of posts a boost::shared_pointer
to a class having the pointer
to the chart, so the WtTermina::plot will be something like this:
Wt::WStandardItemModel* myDataModelBuffer = new Wt::WStandardItemModel(...)
Wt::WServer::instance()->post(theSessionId,
boost::bind(&ChartOwner::swapModel,
boost::shared_pointer(theChartOwner),
myDataModelBuffer));
This way when the WtTerminal is destroyed and there are still pending
posts the ChartOwner survives
the WtTerminal. So far so good.
Now the question is: the user decides to close the chart, it pushes a
button blocking the posts to be
"delivered", the chart is destroyed having a parent (being destroied),
when the Wt loop ends then the
post still in the queue are delivered but the ChartOwner has now an
invalid pointer!
How to solve this?
Gaetano
--
cpp-today.blogspot.com
------------------------------------------------------------------------------
vRanger cuts backup time in half-while increasing security.
With the market-leading solution for virtual backup and recovery,
you get blazing-fast, flexible, and affordable data protection.
Download your free trial now.
http://p.sf.net/sfu/quest-d2dcopy1
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest