sergey.pozhidaev Posted December 19, 2013 Share Posted December 19, 2013 (edited) Hello. Why an error occurs during processing of user class with vector by Reflection Class?For example, I have the following class: class MyClass { private: int myVector[0] = (1, 2, 3); public: MyClass() {} void addItem(int value) { myVector.append(value); } int getItem(int num) { return myVector[num]; } int getNumItems() { return myVector.size(); } }; I use this class in Init() function: int init() { MyClass my_class = new MyClass(); my_class.addItem(4); forloop(int i = 0; my_class.getNumItems()) { log.message("item[%d] = %d;\n", i, my_class.getItem(i)); } /* Output: * item[0] = 1; * item[1] = 2; * item[2] = 3; * item[3] = 4; */ Reflection my_reflection = new Reflection(); my_reflection.reflect(my_class); // here is an error return 1; } And i have following error: Assertion: '(unsigned int)index < (unsigned int)length && "Vector::operator[](): bad index" ' Update: I initialize the vector in constructor, but the probled remained. Then I just declared a variable in the class and the problem disappeared. But this variable is unused.Code: class MyClass { private: int myVector[0]; int i; public: MyClass() { myVector = (1,2,3); } void addItem(int value) { myVector.append(value); } int getItem(int num) { return myVector[num]; } int getNumItems() { return myVector.size(); } }; Edited December 19, 2013 by sergey.pozhidaev Link to comment
silent Posted December 19, 2013 Share Posted December 19, 2013 Hi Sergey, Thank you! This issue is passed to the developers. 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
frustum Posted December 25, 2013 Share Posted December 25, 2013 Thanks. Will be fixed in the next SDK update. Link to comment
Recommended Posts