Home > Mobile >  Pure virtual method called problem
Pure virtual method called problem

Time:11-29

Small white to ask a question: button click the concurrent calls a method (as follows: getTextContent), leading to pure virtual method called,
Reason is probably concurrent call operation members of the same class pointer (because of the need to be done in an asynchronous callback deleteLater so can't is local stated, affected by the scope), in an operation deleteLater after another operation and carried out a virtual function pointer has been the last operation destructor, result in abnormal, how to deal with this situation?
In addition to limit a single request are there any other way? Best can support concurrent calls at the same time, many thanks!

Pseudo code is as follows:
Void Form: : getTextContent () {
API=new HttpAPI ();
API - & gt; GetTextContent ([& amp;] (bool success, QList The list) {
//an asynchronous callback
Int the error=1;
QString MSG="";
If (success) {
QListIterator Iter (list);
QPair Pair;
While (iter) hasNext ())
{
Pair=iter. Next ();
Error=pair. First;
MSG=pair. The second;
}

If (error==0) {
//to perform certain operations
}
}
API - & gt; DeleteLater ();
});
}
  •  Tags:  
  • Qt
  • Related