Page 1 of 1

Assertion on IxValidatorX.cpp, line 78

PostPosted: Tue Feb 22, 2022 11:56 am
by lixb
Hi,

I meet an Assert Error in file IxValidatorX.cpp, line 78, when running an insert-query.
ASSERT: "m_pClass" in file ../QxOrm/src/QxValidator/IxValidatorX.cpp, line 78

code:
Code: Select all
template<class T>
void dbInsert(QList<T> &daoList){
    QSqlDatabase db = qx::QxSqlDatabase::getDatabase();
    QSqlError sqlError = qx::dao::insert(daoList, &db);
    ...
}


The assert occurs, not every time, when qx::dao::insert(daoList, &db) is called.
dbInsert(QList<T> &daoList) may be called in several threads. daoList has been checked already.

Could you please tell me what's happening and how to fix it?

Thank you!

Re: Assertion on IxValidatorX.cpp, line 78

PostPosted: Mon Feb 28, 2022 4:19 pm
by qxorm
Hello,
not every time

This is strange, I don't understand what could be wrong.
Have you written some validators methods for your persistent classes ?

Anyway, maybe you could try to register all QxOrm context at the beginning of your program (in your main function for example, or where you initialize your database connexion) :
Code: Select all
// Following command is recommanded to initialize QxOrm introspection engine
qx::QxClassX::registerAllClasses(true);

Re: Assertion on IxValidatorX.cpp, line 78

PostPosted: Tue Mar 01, 2022 6:19 am
by lixb
Thanks for your reply.
No validator methods written. And qx::QxClassX::registerAllClasses() is already called in main function. :(

Re: Assertion on IxValidatorX.cpp, line 78

PostPosted: Tue Mar 01, 2022 1:23 pm
by qxorm
Maybe you could try to :
- after calling qx::QxClassX::registerAllClasses(true); in your main function,
- add something like this :
Code: Select all
qx::QxCollection<QString, qx::IxClass *> * pAllClasses = qx::QxClassX::getSingleton()->getAll();
for (long k = 0; k < pAllClasses->count(); k++) {
   qx::IxClass * pClass = pAllClasses->getByIndex(k); if (! pClass) { continue; }
   pClass->getAllValidator(); // this line should initialize the 'm_pClass' variable where your assertion is thrown
}


If it resolves your issue, I will add it inside the 'registerAllClasses()' method for the next version.

Re: Assertion on IxValidatorX.cpp, line 78

PostPosted: Thu Mar 03, 2022 12:43 am
by lixb
Got it.
It may take several days to confirm. I will let you know.

Re: Assertion on IxValidatorX.cpp, line 78

PostPosted: Tue Mar 15, 2022 9:28 am
by lixb
qxorm wrote:Maybe you could try to :
- after calling qx::QxClassX::registerAllClasses(true); in your main function,
- add something like this :
Code: Select all
qx::QxCollection<QString, qx::IxClass *> * pAllClasses = qx::QxClassX::getSingleton()->getAll();
for (long k = 0; k < pAllClasses->count(); k++) {
   qx::IxClass * pClass = pAllClasses->getByIndex(k); if (! pClass) { continue; }
   pClass->getAllValidator(); // this line should initialize the 'm_pClass' variable where your assertion is thrown
}


If it resolves your issue, I will add it inside the 'registerAllClasses()' method for the next version.


It works! Thank you!