Problem with persistent class registration

Forum for posting problems using QxOrm library

Problem with persistent class registration

Postby Guest » Wed Apr 11, 2012 4:54 pm

Hi,

I tried to use the example provided in the FAQ to update my database schema based on the persistent classes registered in the context.

My application crashes when this line is executed in the updateDatabaseVersion() function:

Code: Select all
qx::QxCollection<QString, qx::IxClass *> * pAllClasses = qx::QxClassX::getAllClasses();


I debugged a little and what is making it crash is the assert in the registerAllClasses() function:

Code: Select all
while (itr.hasNext())
   {
      itr.next();
      IxClass * pClass = QxClassX::getClass(itr.key());
      qAssert(pClass != NULL); Q_UNUSED(pClass); // <--- this line
   }


Apparently the classes are not registered correctly, or maybe I forgot to do something (application is working just fine though, I just have problems with introspection).

What could be the problem?

Thanks.
Guest
 

Re: Problem with persistent class registration

Postby talnicolas » Wed Apr 11, 2012 8:16 pm

A few more details:

I think it is due to the fact that I'm using a namespace: when calling

Code: Select all
bool QxClassX::insert(const QString & sKey, IxClass * pClass)


the key is "foo::bar::MyClass", but in the registerAllClasses() (when the getAllClasses() is called):

Code: Select all
IxClass * pClass = QxClassX::getClass(itr.key());


the key in this case is "MyClass", so the pointer is always NULL.
talnicolas
 
Posts: 3
Joined: Tue Feb 21, 2012 7:37 pm

Re: Problem with persistent class registration

Postby QxOrm admin » Thu Apr 12, 2012 10:04 am

Hi,

I think it is due to the fact that I'm using a namespace...
...the key is "foo::bar::MyClass"...
...the key in this case is "MyClass", so the pointer is always NULL.

For classes into namespace, there is a Q&R in the FAQ : http://www.qxorm.com/qxorm_en/faq.html#faq_150
And you have an example of namespace with CPerson class into './test/qxDllSample/dll1/include/' directory.
You should try to compare your class with the example CPerson class.

Could you provide please your full source code of your 'foo::bar::MyClass' class (*.hpp and *.cpp files) ?
QxOrm admin
 

Re: Problem with persistent class registration

Postby talnicolas » Thu Apr 12, 2012 1:17 pm

Actually I found my solution. My problem was that I thought that this would work:

Code: Select all
using namespace foo::bar;

QX_REGISTER_COMPLEX_CLASS_NAME_CPP_SM_INSPECTOR(MyClass, foo_bar_MyClass)


but it had to be:

Code: Select all
using namespace foo::bar;

QX_REGISTER_COMPLEX_CLASS_NAME_CPP_SM_INSPECTOR(foo::bar::MyClass, foo_bar_MyClass)


So I just didn't think of adding the namespace in the macro. Thanks anyway!
talnicolas
 
Posts: 3
Joined: Tue Feb 21, 2012 7:37 pm


Return to QxOrm - Help

Who is online

Users browsing this forum: No registered users and 2 guests