Adnan RIHAN
2014-10-13 22:38:47 UTC
Hi there,
---------------------
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”.
--
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).
QSharedPointer<Object> obj1(new Object(...));
QSharedPointer<Object> obj2(obj1);
return (obj1 == obj2);
byQSharedPointer<Object> obj2(obj1);
return (obj1 == obj2);
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.QSharedPointer<Object> obj2(obj1);
return (*obj1->data() == *obj2->data());
---------------------
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”.
[...] // 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);
}
}
[...] // Some Qt’s headers
# include <odb/core.hxx>
# include "../AbstractModel.hpp"
# include "../Product/Product.hpp"
class Offer : public AbstractModel
{
[...]
quint8 m_id;
QSharedPointer<Product> m_product;
float m_price;
}
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?# 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);
}
}
[...] // Some Qt’s headers
# include <odb/core.hxx>
# include "../AbstractModel.hpp"
# include "../Product/Product.hpp"
class Offer : public AbstractModel
{
[...]
quint8 m_id;
QSharedPointer<Product> m_product;
float m_price;
}
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
--
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).