sergey.pozhidaev Posted April 27, 2015 Share Posted April 27, 2015 Unigine::Ptr now cant be used with qt containers because of missing placement new operator. please, fix it. Link to comment
silent Posted April 27, 2015 Share Posted April 27, 2015 sergey.pozhidaev Could you please give us more details about this issue? Our Qt samples are working fine out of the box. How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
sergey.pozhidaev Posted April 27, 2015 Author Share Posted April 27, 2015 For example : QMap <int, Unigine::ObjectMeshDynamicPtr> or QVector <Unigine::ImagePtr> Node *createNode(const Key &k, const T &v, Node *parent = 0, bool left = false) { Node *n = static_cast<Node *>(QMapDataBase::createNode(sizeof(Node), Q_ALIGNOF(Node), parent, left)); QT_TRY { new (&n->key) Key(k); QT_TRY { new (&n->value) T(v); // error } QT_CATCH(...) { n->key.~Key(); QT_RETHROW; } } QT_CATCH(...) { QMapDataBase::freeNodeAndRebalance(n); QT_RETHROW; } return n; } Link to comment
unclebob Posted April 27, 2015 Share Posted April 27, 2015 Well, Unigine::Ptr class has its own placement new and delete operators, please check UniginePtr.h file, line 126: UNIGINE_DECLARE_USE_MEMORY That macro contained all placement new & delete operator declarations. File UnigineBase.h, line 125 #define UNIGINE_DECLARE_USE_MEMORY \ static UNIGINE_INLINE void *operator new(size_t size) { return Unigine::Memory::allocate(size); } \ static UNIGINE_INLINE void *operator new[](size_t size) { return Unigine::Memory::allocate(size); } \ static UNIGINE_INLINE void operator delete(void *ptr) { Unigine::Memory::deallocate(ptr); } \ static UNIGINE_INLINE void operator delete[](void *ptr) { Unigine::Memory::deallocate(ptr); } \ static UNIGINE_INLINE void operator delete(void *ptr,size_t size) { Unigine::Memory::deallocate(ptr,size); } \ static UNIGINE_INLINE void operator delete[](void *ptr,size_t size) { Unigine::Memory::deallocate(ptr,size); } So I'm not sure if the problem is related to missed placement new operator. Link to comment
sergey.pozhidaev Posted April 28, 2015 Author Share Posted April 28, 2015 Yes, this all about UNIGINE_DECLARE_USE_MEMORY, we are comment it & now it works for us. but somehow placement new operator is not present when other new operators has overloaded. i am not sure, but it is not possible to overload placement new operator in c++. so, is commenting UNIGINE_USE_MEMORY good solution? Link to comment
unclebob Posted April 29, 2015 Share Posted April 29, 2015 Sergey, Commenting UNIGINE_DECLARE_USE_MEMORY is definitely not a good solution as it may lead you into some serious memory corruptions, especially if you're going to create nodes and share them between UnigineScript and C++. Link to comment
sergey.pozhidaev Posted June 29, 2015 Author Share Posted June 29, 2015 can you fix it for support QT Vector & Maps? Link to comment
silent Posted July 3, 2015 Share Posted July 3, 2015 Hi Sergey, can you fix it for support QT Vector & Maps? Any chance to get a small sample for reproduction, so we can check what we can do? Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
sergey.pozhidaev Posted July 6, 2015 Author Share Posted July 6, 2015 QVector<Unigine::NodePtr> nodes; QMap<Unigine::NodePtr,int>; this strings will rise error on compile in QT Link to comment
silent Posted July 6, 2015 Share Posted July 6, 2015 Hi Sergey, If I understand you correctly, the minimal reproduction sample will be something like this: #include <QVector> #include <QMap> #include <UnigineNode.h> using namespace Unigine; void my_func(){ QVector<Unigine::NodePtr> nodes; nodes.append(Unigine::NodePtr(NULL)); QMap<Unigine::NodePtr,int> nodes2; nodes2.insert(Unigine::NodePtr(NULL), 1); } int main() { my_func(); } Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
Recommended Posts