Hi All,

The Coverity Scan has picked up what it thinks is a defect in
QGraphicsViewAdapter:

https://scan9.coverity.com/reports.htm#v25753/p12834/fileInstanceId=5614557&defectInstanceId=1105702&mergedDefectId=124679

I've looked at the relevant code, copy and pasted below for reference.
The issue looks to be related to mixing an int key value with the
enum's defined in osgGA::GUIEventAdapter.  I presume the key value is
coming in from a Qt event, though I'm not 100% clear on this as I'm
not the author of this code, no have Qt expertise.

It would really helpful for those with some Qt expertise to dive in
and review the code and the Coverity Scan defect to see what the
resolution should be.

If we can fix this defect then osgQt will be "defect" free as far as
Coverity Scan is concerned :-)

Robert.


-- problem src/osgQt/QGraphicsViewAdapter.cpp method:

bool QGraphicsViewAdapter::handleKeyEvent(int key, bool keyDown)
{
    QEvent::Type eventType = keyDown ? QEvent::KeyPress : QEvent::KeyRelease;

    OSG_INFO<<"sendKeyEvent("<<key<<", "<<keyDown<<")"<<std::endl;

    if (key==osgGA::GUIEventAdapter::KEY_Shift_L ||
key==osgGA::GUIEventAdapter::KEY_Shift_R)
    {
        _qtKeyModifiers = (_qtKeyModifiers & ~Qt::ShiftModifier) |
(keyDown ? Qt::ShiftModifier : Qt::NoModifier);
    }

    if (key==osgGA::GUIEventAdapter::KEY_Control_L ||
key==osgGA::GUIEventAdapter::KEY_Control_R)
    {
        _qtKeyModifiers = (_qtKeyModifiers & ~Qt::ControlModifier) |
(keyDown ? Qt::ControlModifier : Qt::NoModifier);
    }

    if (key==osgGA::GUIEventAdapter::KEY_Alt_L ||
key==osgGA::GUIEventAdapter::KEY_Alt_R)
    {
        _qtKeyModifiers = (_qtKeyModifiers & ~Qt::ControlModifier) |
(keyDown ? Qt::ControlModifier : Qt::NoModifier);
    }

    if (key==osgGA::GUIEventAdapter::KEY_Meta_L ||
key==osgGA::GUIEventAdapter::KEY_Meta_R)
    {
        _qtKeyModifiers = (_qtKeyModifiers & ~Qt::MetaModifier) |
(keyDown ? Qt::MetaModifier : Qt::NoModifier);
    }

    Qt::Key qtkey;
    QChar input;

    KeyMap::iterator itr = _keyMap.find(key);
    if (itr != _keyMap.end())
    {
        qtkey = itr->second;
    }
    else
    {
        qtkey = (Qt::Key)key;
        input = QChar(key);
    }

    QKeyEvent event(eventType, qtkey, _qtKeyModifiers, input);
    QCoreApplication::sendEvent(_graphicsScene.data(), &event);
    return true;
}
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to