What does _QX_ENABLE_BOOST_SERIALIZATION_POLYMORPHIC do?
It is explained in the manual here :
http://www.qxorm.com/qxorm_en/manual.html#manual_630This flag just enables another boost serialization module (the polymorphic one, more details on
boost serialization documentation).
But I don't think it will help you with your issue.
From first glance I don't see how you avoided the issue of double delete...?
Just changing the way I called
qx::clone() function, now it works with :
- Code: Select all
boost::shared_ptr<myClass> * pCloneTemp = qx::clone_to_nude_ptr(other);
boost::shared_ptr<myClass> pClone = (pCloneTemp ? (* pCloneTemp) : boost::shared_ptr<myClass>());
if (pCloneTemp) { delete pCloneTemp; pCloneTemp = NULL; }
// Now use pClone....
As I said, the problem is the double deletion of the root item of your tree when it is referenced somewhere else in the tree.
boost serialization keeps a trace of a same pointer to reuse it later.
So if your root item is encapsulated in a smart-pointer somewhere else in your tree, and if you encapsulate also this root item directly in a smart-pointer yourself calling qx::clone(), then you have 2 smart-pointers on the same instance ==> double deletion ==> crash.
The 3 lines of code I gave you to call qx::clone() function (in fact qx::clone_to_nude_ptr() function) is just a way to protect the root item of your tree to double deletion (no 2 different smart-pointer which take ownership of a same raw pointer).
Instead of json, what if I just used the QByteArray serialize?
I think you mean Qt QDataStream serialization (using
qx::serialization::qt namespace) : no, I tried it when I had the same issue with QxEntityEditor : the problem is when you enable boost serialization, QDataStream will continue to use boost serialization for some containers ==> so you will certainly have the same issue.
JSON serialization is safe because it will not use boost serialization at all, and it will not keep a trace of a same pointer used several times in the tree.
it says somewhere in the documentation that without boost support you get limited binary serialization. Fair, but what does limited mean?
I improved that in QxOrm 1.4.2 : the goal is to not have to deal with boost serialization, and this is why boost serialization is not required now by QxOrm library by default (it reduces also a lot compilation times).
So "limited" is less true now, but boost serialization provides many features like keep a trace of a same pointer for example.
If I have a custom type and use the Qt binary serialize do I need to define those transforms for my custom property types? I think somewhere in Qt documentation it specifies you can write QByteArray operator<<(customtype) stream operators. I've just never actually done it.
QxOrm library provides already a lot of operator<< to serialize automatically basic types, containers, smart-pointers, etc...
This is why you didn't have to write them until now.
All classes registered in QxOrm context can be serialized without writing these operators.
For custom types which are not supported by QxOrm library, it is explained in the manual here :
http://www.qxorm.com/qxorm_en/manual.html#manual_460