Check the value of "this", in your debugger...
Mostlikely its NULL or invalid
Scott
From: qt-interest-bounces+scott.bloom=onshorecs.com at qt.nokia.com
[mailto:qt-interest-bounces+scott.bloom=onshorecs.com at qt.nokia.com] On
Behalf Of Sajjad
Sent: Saturday, July 23, 2011 6:05 AM
To: qt-interest at trolltech.com
Subject: [Qt-interest] QMap container issue
Hello forum,
I am trying to implement a graph data-structure using QMap<QString,int>
and QVector<Node*> .
QMap<> contains the node name and index of the QVector so that i can
accesss the Node* directly.
And i have the following function to retrieve the index for the vector
to retrieve the node
////////////////////////////////////////////////////////////////////////
//
int SceneHierarchy::getNodeIndex(const QString &nodeName) const
{
int pos = -1;
//find the node in the map with the key - node name
QMap<QString,int>::const_iterator iter =
m_nodeMap.constFind(nodeName);
if(iter == m_nodeMap.constEnd())
{
//node name is not found in the map
pos = -1;
}
else
{
//!node found inside the map and so we
//!return the index of the node in the vector list
pos = iter.value();
}
return pos;
}
////////////////////////////////////////////////////////////////////////
////
The program crashes at the following line
QMap<QString,int>::const_iterator iter =
m_nodeMap.constFind(nodeName);
I do not get what could be the possible problem with the above code. If
the name is not found it will simply returns constEnd(), right?
I must be missing something. Anyone in the forum help to point it out?
Thanks
Sajjad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110723/88d16ec5/attachment.html