Hi,

I have these two situations:
Qt Code:
  1. class myClass
  2. {
  3. ...
  4. }
  5.  
  6. class myModel : public QAbstractTableMOdel
  7. {
  8. public:
  9. ...
  10. Q_INVOKABLE myClass getElement(int index)
  11. {
  12. if(0 > index || index >= m_Data.size())
  13. return 0;
  14.  
  15. return m_Data[index];
  16. }
  17.  
  18. private:
  19. QList<myClass> m_Data;
  20. }
To copy to clipboard, switch view to plain text mode 
calling the getElement(index) function from qml works just fine. However, if I change to pointers like so:
Qt Code:
  1. class myClass : public QObject
  2. {
  3. Q_OBJECT
  4. ...
  5. }
  6.  
  7. class myModel : public QAbstractTableMOdel
  8. {
  9. public:
  10. ...
  11. Q_INVOKABLE myClass* getElement(int index)
  12. {
  13. if(0 > index || index >= m_Data.size())
  14. return 0;
  15.  
  16. return m_Data[index];
  17. }
  18.  
  19. private:
  20. QList<myClass*> m_Data;
  21. }
To copy to clipboard, switch view to plain text mode 
Then it first works fine as well. But every now and then I get a segfault when calling the getElement(index) function from qml. I don't understand how it can work most of the time but suddenly create a segfault. Also, I have no clue how to debug it any further. I narrowed it down to the actual function call but I have no clue why it would give a segfault. Can anyone tell my why this might be happening?