jkriege2 / JKQtPlotter

an extensive Qt5 & Qt6 Plotter framework (including a feature-richt plotter widget, a speed-optimized, but limited variant and a LaTeX equation renderer!), written fully in C/C++ and without external dependencies
http://jkriege2.github.io/JKQtPlotter/index.html
GNU Lesser General Public License v2.1
889 stars 190 forks source link

Runtime error JKQTPDatastore::addItem #144

Open US3RN2ME opened 2 weeks ago

US3RN2ME commented 2 weeks ago

I am trying to run BarChart example with Qt6 and this is what I get:

When things coming to the first addCopiedColumn, I got exception

size_t columnX=ds->addCopiedColumn(X, Ndata, "x"); // unhandled exception

I have traced the exception and it lead to addItem method which invokes QMap::insert method which causes exception

size_t JKQTPDatastore::addItem(JKQTPDatastoreItem* item) {
    /*items.push_back(item);
    return items.size()-1;*/
    items.insert(maxItemID, item); // exception is thrown from insert method
    maxItemID++;
    return maxItemID-1;
}

QMap::insert, basically the line where exception is thrown

iterator insert(const Key &key, const T &value)
{
    const auto copy = d.isShared() ? *this : QMap(); // Exception 0xc0000005 encountered at address 0x7ff84ac7ca71: Access violation reading location 0xffffffffffffffff
    detach();
    return iterator(d->m.insert_or_assign(key, value).first);
}

Exception occurs because of 'd' member variable which has such declaration inside QMap:

    using Map = std::map<Key, T>;
    using MapData = QMapData<Map>;
    QtPrivate::QExplicitlySharedDataPointerV2<MapData> d;