I am using Qt 4.7.4 with MS Visual C++ 2010.
I am using the following QMap:
QMap<T_FileMapKey, HANDLE> m_oMapHistHandle;
where T_FileMapKey is defined as:
typedef struct tagT_FileMapKey
{
int iSubscriptIdx;
int iFilterIdx_1;
int iFilterIdx_2;
} T_FileMapKey;
In order to get the whole thing going, I have overloaded the < operator:
bool operator< (const T_FileMapKey& tVal1, const T_FileMapKey& tVal2)
{
if(tVal1.iSubscriptIdx < tVal2.iSubscriptIdx)
{
return true;
}
else
{
if(tVal1.iFilterIdx_1 < tVal2.iFilterIdx_1)
{
return true;
}
else
{
if (tVal1.iFilterIdx_2 < tVal2.iFilterIdx_2)
{
return true;
}
else
{
return false;
}
}
}
};
As you may predicted this entire operation is to store file handles in a 3 dimensional array like order. I am using a QMap since only a few combinations of the indexes is used and they may be large numbers.
My problem is:
if (INVALID_HANDLE_VALUE == m_oMapCurrHandle.value(tFileKey, fdInvalidHandle))
....
and
if (false == m_oMapHistHandle.contains(tFileKey))
....
(where tFileKey is a T_FileMapKey variable) does not always return the correct value.
Under normal circumstances the QMap is growing over the time, meaning that if a new index combination is encountered a file is opened and the entry is added to the QMap. If I launch the application in debug mode the Qt Visual Studio Add-in allows me to peek into the stored key-value pairings. I can see that the entry in the debug Watch is present (e.g. {0, 32767, 0}) but the two function calls (contains and value) tell me that the QMap does not have such key stored. Usually this behavior is encountered after the QMap has at least 15 key-value pairs.
May this be a bug in Qt 4.7.4? What am doing wrong?