[Qt-interest] assert error in qmap "item_exists()"

André Somers andre at familiesomers.nl
Tue Apr 13 08:24:44 CEST 2010


You could simplify the code a little bit:

void PiezoJenaController::mapStageToChannel(PiezoStage stage, int channel)
{
    stageToChannelMap.insert(stage, channel);  
}

No need to check if the value is already there, it will be replaced
automatically if it is.

André


-----Oorspronkelijk bericht-----
Van: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] Namens Matthias Pospiech
Verzonden: maandag 12 april 2010 16:58
Aan: qt-interest at trolltech.com
Onderwerp: [Qt-interest] assert error in qmap "item_exists()"

The assert error happens in qmap.h in this line:
Q_DECLARE_ASSOCIATIVE_ITERATOR(Map)

The QMap I am using contains 3 values which I can insert with no problem 
or error.
However if I try to access the value (last line) I get this assertion:

    QMapIterator<PiezoStage, int> i(stageToChannelMap);
    while (i.hasNext()) {
        if (i.value() == currentChannel) {...


The map is filled using:

    piezoController->mapStageToChannel(PiezoJenaController::X, 0);
    piezoController->mapStageToChannel(PiezoJenaController::Y, 1);
    piezoController->mapStageToChannel(PiezoJenaController::Z, 2);

with:

void PiezoJenaController::mapStageToChannel(PiezoStage stage, int channel)
{
    if (stageToChannelMap.contains(stage)) {
        stageToChannelMap[stage] = channel;
    } else {
        stageToChannelMap.insert(stage, channel);
    }   
}


What am I possibly doing wrong?
Matthias
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest





More information about the Qt-interest-old mailing list