[odb-users] libc++abi.dylib: terminating with uncaught foreign
exception
Adnan RIHAN
axel50397 at gmail.com
Mon Oct 13 18:38:47 EDT 2014
Hi there,
I sometimes have this error (libc++abi.dylib: terminating with uncaught exception) and last time it was because ODB was trying to cast 2 types it didn’t know... I don’t remember exactly but I removed this error by changing this line in my program (cleaned example):
> QSharedPointer<Object> obj1(new Object(...));
> QSharedPointer<Object> obj2(obj1);
>
> return (obj1 == obj2);
by
> QSharedPointer<Object> obj1(new Object(...));
> QSharedPointer<Object> obj2(obj1);
>
> return (*obj1->data() == *obj2->data());
The thing strange is that QSharedPointer::operator==() checks if the internal pointers are the same. But I don’t remember why, changing to the 2nd block (which is what I wanted because my Object::operator==() really checks the equality) removed the runtime error.
---------------------
Today I’m in another situation, the “uncaught” exception is now “uncaught foreign exception” and I can’t find an exception related to “foreign keys”.
Here is my code and the line prepended with “**” which causes the exception:
> [...] // Some Qt’s headers
> # include <odb/database.hxx>
> # include <odb/qt/list.hxx>
> # include <odb/session.hxx>
> # include <odb/transaction.hxx>
>
> class EntityManager : public QObject
> {
> [...]
> template <typename T>
> QOdbList<QSharedPointer<T> > all(void)
> {
> QOdbList<QSharedPointer<T> > list;
>
> try {
> odb::session s;
> odb::transaction t(this->m_db->begin());
> qDebug() << "Before query”; // SHOWN
> ** odb::result<T> r(this->m_db->query<T>());
> qDebug() << "After query”; // exception before this line
>
> for (typename odb::result<T>::iterator i(r.begin()); i != r.end(); ++i) {
> list.append(QSharedPointer<T>(new T(*i)));
> }
>
> t.commit();
> } catch (const odb::exception &e) {
> qDebug() << "ODB Exception:" << e.what();
> }
>
> return (list);
> }
> }
Here is my “Object” containing the foreign key:
> [...] // Some Qt’s headers
> # include <odb/core.hxx>
> # include "../AbstractModel.hpp"
> # include "../Product/Product.hpp"
> class Offer : public AbstractModel
> {
> [...]
> private:
> quint8 m_id;
> QSharedPointer<Product> m_product;
> float m_price;
> }
Here is my odb command line for the concerned class:
> odb --changelog apps/LGC/schemas/odb-changelog.xml -d sqlite -p qt -q -s --schema-name LGC -o apps/LGC/src/Models/Product apps/LGC/src/Models/Product/Product.hpp 2>&1
> odb --changelog apps/LGC/schemas/odb-changelog.xml -d sqlite -p qt -q -s --schema-name LGC -o apps/LGC/src/Models/Offer apps/LGC/src/Models/Offer/Offer.hpp 2>&1
Any idea?
--
Cordialement, Adnan RIHAN.
Directeur-Gérant de Eolis-Software, société de services informatiques.
GPG: 5675-62BA (https://keybase.io/max13/key.asc)
-> Si vous n'utilisez pas GPG mais souhaitez quand même m’envoyer un e-mail chiffré: (https://encrypt.to/0x567562BA).
More information about the odb-users
mailing list