c++ - Cleaning up a stack of pointers -
i'm having few problem cleaning stack of pointers. in below line delete crashes: "memory fault/segmentation fault".
std::stack<reports*> stack; while(db.fetch()) { reports* report = new report(db); qthreadpool::globalinstance()->start(report); stack.push(report); } while( qthreadpool::globalinstance()->activatethreadcount() != 0 ); while( !stack.empty() ) { delete stack.top(); stack.pop(); }
the context of code think not relevant. except that: db passed reference report constructor, copy necessary current row data non pointer members. can give me hint ?
edit:
self answer:
ok touch god lights after writing question.
by default
qthreadpool::globalinstance()->start(report);
will take ownership of object. adding following line in loop solves problem:
report->setautodelete(false);
or symply not cleaning up... myself , let qt it.
ok touch god lights after writing question.
by default
qthreadpool::globalinstance()->start(report);
will take ownership of object. adding following line in loop solves problem:
report->setautodelete(false);
or symply not cleaning up... myself , let qt it.
Comments
Post a Comment