McKee
9th October 2007, 21:43
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.
connect(&m_MyTimer,SIGNAL(timeout()),this,SLOT(MyTimeout()) );
The failure is at the 4th line of the body of the following Qt library function (at the for loop).
int QMetaObject::indexOfSlot(const char *slot) const
{
int i = -1;
const QMetaObject *m = this;
while (m && i < 0) {
for (i = priv(m->d.data)->methodCount-1; i >= 0; --i)
if ((m->d.data[priv(m->d.data)->methodData + 5*i + 4] & MethodTypeMask) == MethodSlot
&& strcmp(slot, m->d.stringdata
+ m->d.data[priv(m->d.data)->methodData + 5*i]) == 0) {
i += m->methodOffset();
break;
}
m = m->d.superdata;
}
return i;
}
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
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.
connect(&m_MyTimer,SIGNAL(timeout()),this,SLOT(MyTimeout()) );
The failure is at the 4th line of the body of the following Qt library function (at the for loop).
int QMetaObject::indexOfSlot(const char *slot) const
{
int i = -1;
const QMetaObject *m = this;
while (m && i < 0) {
for (i = priv(m->d.data)->methodCount-1; i >= 0; --i)
if ((m->d.data[priv(m->d.data)->methodData + 5*i + 4] & MethodTypeMask) == MethodSlot
&& strcmp(slot, m->d.stringdata
+ m->d.data[priv(m->d.data)->methodData + 5*i]) == 0) {
i += m->methodOffset();
break;
}
m = m->d.superdata;
}
return i;
}
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