Hello all:

I have defined a new class which inherits from QObject but when I try to invoke the QObject::metaObject() function from an instance of this object I get an access violation exception. Does anyone know why I cannot call the QObject::metaObject() function???

This is the call to the function from the object pointer pendingMsgs which generates the exception:


Qt Code:
  1. PendingList *pendingMsgs = new PendingList(this, settings->value("GENERAL/CheckTimeoutInterval").toInt());
  2. const QMetaObject *meta = pendingMsgs->metaObject();
To copy to clipboard, switch view to plain text mode 


And this is the class that I have defined (PendingList):

Qt Code:
  1. #include "MM.h"
  2. #include "Message.h"
  3. #include <QTimer>
  4.  
  5. struct PendingMsg
  6. {
  7. Message request; //message pending to receive a response
  8. CMD cmd; // type of the pending response {ACK or ORD_RESP}
  9. int timeout; // Time that can be stored the message before emitting a timeout signal
  10.  
  11. PendingMsg(Message m, CMD c, int t)
  12. {
  13. request = m;
  14. cmd = c;
  15. timeout = t;
  16. };
  17.  
  18. QString display() const
  19. {
  20. //return "[" + cmdTags[cmd] + " (" + cmdTags[request.getCmd()] + "), " + stateNames[newState] + "]";
  21. return "[" + cmdTags[cmd] + " (" + cmdTags[request.getCmd()] + ")]";
  22. };
  23. };
  24.  
  25. class PendingList : public QObject
  26. {
  27.  
  28. Q_OBJECT
  29.  
  30. public:
  31. PendingList(QObject* parent, int time);
  32. ~PendingList(void);
  33.  
  34. bool add(System sys, Message req, CMD cmd, int time);
  35. bool remove(System sys, CMD cmd);
  36.  
  37. void setCheckTimeInterval(int t) { checkTimeInterval = t;};
  38.  
  39. int size() const;
  40. void display() const;
  41.  
  42. private:
  43.  
  44. int checkTimeInterval;
  45. QTimer timer;
  46.  
  47. QList<PendingMsg> list[MAX_CLIENTS];
  48.  
  49. // finds the position of the command cmd inside list[sys]
  50. int match(System sys, CMD cmd) const;
  51.  
  52. bool startIfEmpty();
  53. bool stopIfEmpty();
  54.  
  55. // Reports that the system 'sys' has not sent a message of type 'cmd1' as answer of the message 'req'
  56. void emitTimeout(System sys, CMD cmd, Message req);
  57.  
  58. void emitMatch(System sys, CMD cmd, Message req);
  59.  
  60. private slots:
  61.  
  62. void checkTimeouts();
  63.  
  64. signals:
  65.  
  66. void timeout_ack_insp_mis(System);
  67. void timeout_ack_pause(System);
  68. void timeout_ack_abort(System);
  69. void timeout_ack_resume(System);
  70. void timeout_ack_mosaic(System);
  71. void timeout_ack_weed_map(System);
  72. void timeout_ack_tre_mis(System);
  73. void timeout_resp_insp_mis(System);
  74. void timeout_resp_pause(System);
  75. void timeout_resp_abort(System);
  76. void timeout_resp_resume(System);
  77. void timeout_resp_mosaic(System);
  78. void timeout_resp_weed_map(System);
  79. void timeout_resp_tre_mis(System);
  80.  
  81. void ack_insp_mis(System);
  82. void ack_mosaic(System);
  83. void ack_weed_map(System);
  84. void ack_tre_mis(System);
  85. void ack_unit_ctrl(System);
  86. void ack_abort(System);
  87. void ack_resume(System);
  88. void ack_pause(System);
  89. void resp_insp_mis(System);
  90. void resp_mosaic(System);
  91. void resp_weed_map(System);
  92. void resp_tre_mis(System);
  93. void resp_abort(System);
  94. void resp_resume(System);
  95. void resp_pause(System);
  96. };
To copy to clipboard, switch view to plain text mode