[QT] Segmentation fault by using QList

Hello,
I have a little problem wioth my Qt-5 Program by using a QList-Object. If I call QList::isEmpty or ::size, my program stops and I recieve a Segmentation-fault (SIGSEGV), but I cannot explain this error to me. So, I don't see any errors in my code, but I hope you can help me. Heres my code an some Debug-Information:
1
2
3
4
5
6
7
8
SGraphNode(QString _sName,
               QString _sDescription,
               QPoint _ptPosition) : sName(_sName),
                                     sDescription(_sDescription),
                                     ptPosition(_ptPosition)
    {
        pEdges = new QList<SGraphEdge>();
    }

1
2
3
4
5
6
7
8
9
10
11
 if(!m_pGraph->getNodes()->at(i).pEdges->isEmpty())
            {
                for(int j=0; j<m_pGraph->getNodes()->at(i).pEdges->size();j++)
                {
                    //if(!m_pGraph->getNodes()->at(i).pEdges->at(j).bDrawn)
                    {
                        pPainter->drawLine(m_pGraph->getNodes()->at(i).ptPosition,
                                           m_pGraph->getNodes()->at(i).pEdges->at(j).pNeighbour->ptPosition);
                    }
                }
            }

m_pGraph->getNodes returns a list of SGraphNode-Objects which contain the problematic list.
If I step in the QList-object, I also see that the member "d" in the QList has a very low value (between 0x00 and 0x11)...but I don't know if this helps by solving this problem.
After emitting the SIGSEGV, the debugger jumps into qlist.h, line 93 (inline bool isEmpty() const { return d->end == d->begin; }), but there is no more Informatuion given by the Debugger.

I hope you can help me by solving this problem.

Greetings
Niklas
> pEdges = new QList<SGraphEdge>();
¿is there a good reason for `pEdges' to be a pointer?
¿have you properly coded the destructor, copy constructor and assignment operator?

> m_pGraph->getNodes()->at(i).pEdges->isEmpty()
http://en.wikipedia.org/wiki/Law_of_Demeter

> I also see that the member "d" in the QList has a very low value (between 0x00 and 0x11)...
> but I don't know if this helps by solving this problem.
no idea, you leave out a lot of information
http://www.cplusplus.com/forum/general/112111/
Thank you for your help. I have solved the Problem by using an Object instead of the Pointer for pEdge and by accessing the List-Elements with an iterator.
Topic archived. No new replies allowed.