I'm currently upgrading a graphing GUI based on QCP from a version from 09.06.12, to the most recent version...suffice to say there's been a lot of changes.

I received help a little while ago with the legend, but am now running into another problem when actually running the GUI.

Our GUI is receiving data from a Data Warehouse and associated ROS Topics. Most of the GUI is working, except when I actually start receiving data, at which point it gives me a segmentation fault. I tracked it down through the following functions:

void DeviceData::onNewDataRcvd(const QString& device, long ts, const QVector<int>& index, QVector<double> values)
{
    cout << "DeviceData::onNewDataRcvd" << endl;
    if (!m_devices.contains(device))
    {
        //qDebug() << "Device not found";
        return;
    }

    Device* d = m_devices.value(device);

    // TODO: dump this if later?
    if (!d->hasTimeStamp())
    {
        d->setTimeStamp(ts);
        d->hasTimeStamp(true);
    }

    cout << "DeviceData::onNewDataRcvd Before For Loop" << endl;
    for (int i = 0; i < index.size(); i++)
    {
        cout << "Inside For Loop" << endl;
        if (m_capture)
        {
            cout << "DeviceData::onNewDataRcvd Inside if(m_capture)" << endl;
            Signal* s = d->getSignal(index[i]);
            cout << "DeviceData::onNewDataRcvd After Signal*" << endl;
            if (i < values.size())
            {
                 cout << "Inside values.size() if check" << endl;
                 s->addData(ts, values[i], m_period);
            }
           
            cout << "DeviceData::onNewDataRcvd After addData" << endl;
            //cout << d->getName().toStdString() << "/" << s->getName().toStdString() << " = " << values[i] << endl;
        }
    }
    cout << "End of DeviceData::onNewDataRcvd" << endl;
}

And in that, it stops at s->addData(ts, valuesi], m_period), which is in our signal.cpp file:

void Signal::addData(const long& key, const double& value, const double& period)
{
    cout << "Inside Signal::addData(), Value is " << value << endl;
    cout << "Key is " << key << endl;
    if (m_isSelected && m_dataMapPtr)
    {
        cout << "Inside Signal::addData(), if statement" << endl;
        m_currentvalue = value;
        m_timestamp = key;
        double newKey = key / 1000;

        cout<< "Past value setting, Inside Signal::addData()" << endl;
        cout << "New Key is: " << newKey << endl;
        cout << "Value is: " << value << endl;
        // double newKey = (key - m_device->getTimeStamp()) / 1000.0;
        // m_graphPtr->setPeriod(period);
        m_displayMutex->lock();
        cout << "Past Mutex Lock" << endl; 
        m_dataMapPtr->insert(newKey, QCPData(newKey, value));
        cout << "Past Insert" << endl;
        m_displayMutex->unlock();
        cout << "Past Unlock" << endl;
        addDisplayData(newKey, value);
        cout << "Past addDisplayData" << endl;
        // std::cout << m_name.toStdString() << " (" << m_timestamp << ") = " << value << std::endl;
    }
}

In this bit, every time I click our "Start" button, it prints out "Past Mutex Lock" and then seg faults. I know with seg faults it's usually a memory access thing, so I've tried using different key values or inserting differently, but I still get some sort of seg fault. Though sometimes, the value is 0, positive, or negative, and I'm not sure if that's out of bounds for the function. I'm just generally unsure if this is something on our part that has something to do with our array index, or if this is something that has changed since the updates, and if QCPData and the QCPDataMap interact differently.

Couldn't find something with QCPData in the Examples, so wanted to turn to the support threads. Any advice, ideas, changes, help, etc, would be incredibly appreciated!

Let me know if I need to provide any other information or you need anything else.

Thanks! :)

Jenny T