[Qt-interest] Segmentation fault with QList of pointers in thread
Donal
donaloconnor at gmail.com
Thu Feb 19 00:17:29 CET 2009
Just as I got this email I noticed where I was going wrong.
It was quite a stupid mistake really, as matter of a fact, really stupid.
I was creating a Class that was local to a function and sending this to the
thread and starting it within this function.
By time thread came around again after a sleep the data that was in the
function was destroyed so pointer pointing to invalid memory.
I'm a bit out of programming practice, not good time with my final year
project and all!
Thanks very much for the reply.
Regards,
Donal
On Wed, Feb 18, 2009 at 11:05 PM, Rohan McGovern
<rohan.mcgovern at nokia.com>wrote:
> On Wednesday 18 February 2009, Donal wrote:
>
> >
> > QString command;
> >
> > command = m_sensors[0]->getMode() + m_sensors[0]->getPid() + " "
> > + QString::number(m_sensors[0]->getExpectedBytes());
> >
> >
> > This works perfect BUT when I insert a sleep before it:
> >
> >
> > QString command;
> > MySleepThread::msleep(1000);
> >
> > command = m_sensors[0]->getMode() + m_sensors[0]->getPid() + " "
> > + QString::number(m_sensors[0]->getExpectedBytes());
> >
> >
> > I get a segmentation fault.
> >
>
> Perhaps m_sensors[0] is being deleted during the sleep?
>
> --
> Rohan McGovern
> Qt Software, Nokia
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090218/e7a8bd1f/attachment.html
More information about the Qt-interest-old
mailing list