Hello --

I have a class derived from QObject which has a QTimer member called m_MyTimer. I have a private slot in that object with signature void MyTimeout(). The following call in the class constructor causes a crash.

Qt Code:
  1. connect(&m_MyTimer,SIGNAL(timeout()),this,SLOT(MyTimeout()));
To copy to clipboard, switch view to plain text mode 

The failure is at the 4th line of the body of the following Qt library function (at the for loop).

Qt Code:
  1. int QMetaObject::indexOfSlot(const char *slot) const
  2. {
  3. int i = -1;
  4. const QMetaObject *m = this;
  5. while (m && i < 0) {
  6. for (i = priv(m->d.data)->methodCount-1; i >= 0; --i)
  7. if ((m->d.data[priv(m->d.data)->methodData + 5*i + 4] & MethodTypeMask) == MethodSlot
  8. && strcmp(slot, m->d.stringdata
  9. + m->d.data[priv(m->d.data)->methodData + 5*i]) == 0) {
  10. i += m->methodOffset();
  11. break;
  12. }
  13. m = m->d.superdata;
  14. }
  15. return i;
  16. }
To copy to clipboard, switch view to plain text mode 

In particular, m->d.data is 0.

A workaround is to put the call to connect() in an initialization function that the client of the object is then obliged to call once, but that's annoying. Is there a way to get the connection at construction time?

thanks